React native 反应本机-Can';找不到变量:title
新的本地安装。我正在试着设置它。在index.ios.js中,我有:React native 反应本机-Can';找不到变量:title,react-native,React Native,新的本地安装。我正在试着设置它。在index.ios.js中,我有: class thingy extends Component { render() { return ( <NavigatorIOS style={styles.container} initialRoute={( title: 'Thingy', component: Main )} /> );
class thingy extends Component {
render() {
return (
<NavigatorIOS
style={styles.container}
initialRoute={(
title: 'Thingy',
component: Main
)} />
);
}
}
class thingy扩展组件{
render(){
返回(
);
}
}
当我运行此程序时,应用程序会显示以下错误:
找不到变量:title
我不知道为什么它会给我这个错误。有什么想法吗
主要组成部分:
var React = require('react-native');
var {
View,
Text,
StyleSheet
} = React;
var styles = StyleSheet.create({
mainContainer: {
flex: 1,
padding: 30,
marginTop: 65,
flexDirection: 'column',
justifyContent: 'center',
backgroundColor: '#48BBEC'
},
title: {
marginBottom: 20,
fontSize: 25,
textAlign: 'center',
color: '#fff'
},
searchInput: {
height: 50,
padding: 4,
marginRight: 5,
fontSize: 23,
bordderWidth: 1,
borderColor: 'white',
borderRadius: 8,
color: 'white'
},
buttonText: {
fontSize: 18,
color: '#111',
alignSelf: 'center'
},
button: {
height: 45,
flexDirection: 'row',
backgroundColor: 'white',
borderColor: 'white',
borderWidth: 1,
bordeRadius: 8,
marginBottom: 10,
marginTop: 10,
alignSelf: 'stretch',
justifyContent: 'center'
},
});
class Main extends React.Component{
render(){
return (
<View style={styles.mainContainer}>
<Text> Testing the Router </Text>
</View>
)
}
};
module.exports = Main;
var React=require('React-native');
变量{
看法
文本,
样式表
}=反应;
var styles=StyleSheet.create({
主容器:{
弹性:1,
填充:30,
玛金托普:65,
flexDirection:'列',
为内容辩护:“中心”,
背景颜色:“#48BBEC”
},
标题:{
marginBottom:20,
尺寸:25,
textAlign:'中心',
颜色:'#fff'
},
搜索输入:{
身高:50,
填充:4,
marginRight:5,
尺寸:23,
博尔德宽度:1,
边框颜色:“白色”,
边界半径:8,
颜色:“白色”
},
按钮文字:{
尺码:18,
颜色:'#111',
自我定位:“中心”
},
按钮:{
身高:45,
flexDirection:'行',
背景颜色:“白色”,
边框颜色:“白色”,
边框宽度:1,
波德拉迪乌斯:8,
marginBottom:10,
玛金托普:10,
自我定位:“拉伸”,
为内容辩护:“中心”
},
});
类Main扩展了React.Component{
render(){
返回(
测试路由器
)
}
};
module.exports=Main;
啊,看起来initialRoute
应该是一个对象,但您将其包装在括号中:
现在怎么样:
initialRoute={(
title: 'Thingy',
component: Main
)}
initialRoute={{
title: 'Thingy',
component: Main
}}
实际上应该是:
initialRoute={(
title: 'Thingy',
component: Main
)}
initialRoute={{
title: 'Thingy',
component: Main
}}
你能显示你的
Main
组件代码吗?它现在在那里。这是ES6的新语法吗?