首页 文章

undefined不是一个函数(评估'_reactNativeNavigation2.default.startTabBasedApp')startTabs StartMainTabs.js

提问于
浏览
0

我是新来的原生反应,我只是按照原生导航官方文档进行反应并尝试使用Navigation的startTabBasedApp . 当我尝试从主页面单击Button以重定向实际的startTabBasedApp页面时显示错误:undefined不是一个函数(评估'_reactNativeNavigation2.default.startTabBasedApp') . 我该如何解决这个错误..

undefined不是函数(评估'_reactNativeNavigation2.default.startTabBasedApp')startTabs StartMainTabs.js如何解决此错误...
enter image description here

1 回答

  • 0

    因为在react-native-navigation的v2中不再支持 Navigation.startTabBasedApp() ,所以这可能是问题所在 .

    如果您想创建一个导航按钮,只需按照以下方式操作即可:

    import { Navigation } from "react-native-navigation";
    import React,{ Component } from "react";
    import { View, Button, Text } from "react-native"; 
    
    class YourClass extends Component {
        constructor(props) {
            super(props);
            Navigation.events().bindComponent(this);
        }
    
        navigationButtonPressed({ buttonId }) {
             //page that you wish to navigate 
        }
    
        render() {
             return (
                   <View> 
                        <Button title="Navigate" onPress= {this.navigationButtonPressed("navigate")} />
                   </View>
             )
        }
    }
    

    基于v2文档,您可以在此处阅读,还可以获得安装,使用等指南:https://wix.github.io/react-native-navigation/v2/#/

    快乐的编码!!

相关问题