我创建了一个初始屏幕和一个登录屏幕。我希望两秒钟后我的屏幕闪屏登录,但显示:undefined is not an object(evaluating
'_this.props.navigation.push ')
在这个项目中,我正在使用反应导航
componentWillMount(){
setTimeout(
() => {
this.props.navigation.push({
screen:'smartbill.login',
title:'LOGIN SCREEN'
});
}
, 1000);
}
答案 0 :(得分:1)
希望您已经创建了一个堆栈导航器
const App = createStackNavigator({
Splash: { screen: SplashScreen },
Login: { screen: LoginScreen },
});
在启动画面中
setTimeout(()=> {
navigate('Login', { name: 'Jane' })
},1000);
答案 1 :(得分:0)
下面是我从启动画面导航到主屏幕的示例
setTimeout(
()=> {
this.props.navigation.navigate("Home");
},1000
);
对于导航,您应该在本机方法中使用StackNavigator,这是正确的方法
您从哪里得到的this.props.navigation.push
不正确。
或
我在以下问题中有一个例外答案。
How to navigate from splash screen to login screen in react native?
上面有一个google驱动器链接,您可以从中下载示例项目,其简单的app
可以从示例应用程序中了解如何设置App.js
。
我建议您为StackNavigator
使用 navigation
,因为它是{{1}配置app
中的最佳方法}}。