启动我的应用时出错: 未定义不是对象(评估' route.title')
我希望导航器能够通过“设置”来初始化。路线,因为我是initalRoute = {{title:'设置'}}
如何在初始应用加载时定义路由?
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Navigator
} from 'react-native';
import SetupComponent from './src/setup/setup.component';
import HomeComponent from './src/home/home.component';
export default class AwesomeProject extends Component {
render() {
return (
<Navigator
initalRoute={{ title: 'Setup'}}
renderScene={(route, navigator) => {
console.log("routing", route.title);
if (route.title === 'Setup'){
return <SetupComponent navigator={navigator} />
}
if (route.title === 'Home') {
return <HomeComponent navigator={navigator} />
}
console.log("return default");
}}
/>
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
&#13;
答案 0 :(得分:3)
您的导航器组件定义中存在拼写错误 - 您的代码应为initalRoute
时应为initialRoute
。更改此行,您应该会看到错误已修复。