新升级 到0.46版本以后 Navigator 不能使用报错。
'Navigator is deprecated and has been removed from this package. It can now be installed ' +
'and imported from `react-native-deprecated-custom-components` instead of `react-native`. ' +
'Learn about alternative navigation solutions at http://facebook.github.io/react-native/docs/navigation.html'
解决方案:
1、cd 当前目录
2、npm install react-native-deprecated-custom-components --save
3、import {Navigator} from 'react-native-deprecated-custom-components';
4、
<Navigator initialRoute={{ name: '首页', component: Home }} //配置场景 configureScene= { (route) => { //这个是页面之间跳转时候的动画,具体有哪些?可以看这个目录下, //有源代码的: node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorSceneConfigs.js // return Navigator.SceneConfigs.PushFromRight; return ({ ...Navigator.SceneConfigs.PushFromRight, gestures: null, }); } } renderScene={ (route, navigator) => { let Component = route.component; return <Component {...route.params} navigator={navigator} /> } } />
厚积薄发,笨鸟先飞。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步