新手求助关于navigator的跳转问题



  • 一直提示undefind is not an object(evaluating 'this.props.navigator.push')
    不知道怎么解决啊?
    var regPage=require('./ios_views/page/regPage');
    //一开始定义页面
    <TouchableOpacity
    onPress={() => this.goToNext()}>
    <View>
    <Text>登入</Text>
    </View>
    </TouchableOpacity>
    goToNext:function(){
    this.props.navigator.push({
    component: regPage,
    });
    }



  • 你先把他解构 const{navigator} = this.props.navigator if(navigator){navigator.push({component: regPage,})} 这样试试



  • @wowaji 说:

    <TouchableOpacity
    onPress={() => this.goToNext()}>

    改成

    <TouchableOpacity
    onPress={() => this.goToNext.bind(this)}>

    试试


登录后回复