index.ios.js
render: function() {
return (
<NavigatorIOS
style={styles.navigationContainer}
initialRoute={{
title: "Stories",
component: Stories,
leftButtonTitle : 'blabla',
rightButtonTitle : 'Profile',
onLeftButtonPress: () => {
// this.blabla()
},
onRightButtonPress: () => {
this.goProfile();
}
}} />
);
}
goProfile函数
goProfile : function () {
this.props.navigator.push({
title: 'Profile',
component: profilePage,
leftButtonTitle: 'Home',
});
},
无法读取未定义的属性"推送"这个对象属性在对象中只有rootTag。为什么在第一页应用程序上崩溃.
尝试添加navigator
引用:
ref="navigator"
并推送到参考而不是道具:
goProfile : function () {
this.refs.navigator.push({
title: 'Profile',
component: profilePage,
leftButtonTitle: 'Home',
});
},
因此,您的NavigatorIOS应如下所示:
<NavigatorIOS
ref="navigator"
style={styles.navigationContainer}
initialRoute={{
title: "Stories",
component: Stories,
leftButtonTitle : 'blabla',
rightButtonTitle : 'Profile',
onLeftButtonPress: () => {
// this.blabla()
},
onRightButtonPress: () => {
this.goProfile();
}
}} />