我写了这段代码 lib/helper.js
var myfunction = async function(x,y) {
....
reutrn [variableA, variableB]
}
exports.myfunction = myfunction;
Run Code Online (Sandbox Code Playgroud)
然后我试着在另一个文件中使用它
var helper = require('./helper.js');
var start = function(a,b){
....
const result = await helper.myfunction('test','test');
}
exports.start = start;
Run Code Online (Sandbox Code Playgroud)
我收到了一个错误
"await仅在异步函数中有效"
有什么问题?
我在行上添加了两个元素
render() {
return (
<View style={{ flexDirection: 'row', justifyContent: 'center' }}>
<Icon
name='person'
color='#98999c'
onPress={this.handleClick.bind(this)} />
<Text style={ styles.header }>
{ 'User Name' }
</Text>
</View>
)
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能在它们之间添加空格?
编辑:
我这里也有明智的问题:
const AppNavigator = StackNavigator({
Home: {
screen: AppDrawer,
navigationOptions: ({navigation}) => ({
headerLeft:
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Icon name="menu" size={35} margin={30} padding={30} onPress={ () => navigation.navigate('DrawerOpen') } />
<ChangeLanguage style={{ margin: 30 , padding: 30}} />
</View>,
headerRight:
<HeaderUserInformation />,
})
}
Run Code Online (Sandbox Code Playgroud) 更新到Swift 4后,我收到此代码的错误
attributes["NSFont"] = font
attributes["NSColor"] = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1)
Run Code Online (Sandbox Code Playgroud)
无法使用索引类型为"String"的类型'[NSAttributedStringKey:Any]'下标值
我能够通过替换修复第一行["NSFont"],NSAttributedStringKey.font但我不知道如何修复第二行.
我使用堆栈导航器导航到一个视图.新屏幕有不同的背景颜色#E9E9EF,我不知道它来自哪里.我发现这个颜色是在react-navigation/lib/views/CardStack/Card.js中设置的.我试图改变视图背景颜色,但它没有奏效
return (
<View style={{backgroundColor: '#F5FCFF'}}>
</View>
)
Run Code Online (Sandbox Code Playgroud)
我还尝试在StackNavigator中使用此代码更改卡片样式,颜色没有改变
Other: {
screen: AppOtherContainer,
cardStyle: {backgroundColor: 'red'},
navigationOptions: ({navigation}) => ({
title: navigation.state.params.title
})
}
Run Code Online (Sandbox Code Playgroud) 我正在使用此代码复制文件数据库
try fileManager.copyItem(atPath: storeURL.path, toPath: storeCopyURL.path)
Run Code Online (Sandbox Code Playgroud)
我可以看到创建了一个新的sqlite数据库
以后,当我尝试使用此功能时
try! sharedInstance.managedObjectStore.addSQLitePersistentStore(atPath: storeURL.path, fromSeedDatabaseAtPath: storeCopyURL.path, withConfiguration: nil, options: nil)
Run Code Online (Sandbox Code Playgroud)
我得到一个错误
E restkit.core_data:RKManagedObjectStore.m:299无法从路径复制种子数据库...
我对本机反应很陌生。我在我的应用程序中使用来自react-native-elements的标头。这是我的代码
<Header
leftComponent={{ icon: 'menu', color: '#fff' }}
centerComponent={{ text: 'MY TITLE', style: { color: '#fff' } }}
rightComponent={{ icon: 'home', color: '#fff' }}
/>
Run Code Online (Sandbox Code Playgroud)
我无法找到有关如何检测图标点击的任何示例,并在可能的情况下显示额外视图。我的目标是实现这样的目标:
你有任何示例或示例代码吗?
我想根据条件为我的渲染对象添加一个div.现在我正在使用此代码
render() {
return (
<div>
{this.test === this.someValue ? <div> some view </div> : <div> /div>}
...... // other components
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
这是有效的,但我不喜欢,: <div> /div>因为我不需要它.有没有办法只使用一个if而不是if else?