aiyov
V2EX  ›  问与答

reactNative(StackNavigator 路由跳转不动),求指教

  •  
  •   aiyov · Jan 16, 2018 · 2086 views
    This topic created in 3045 days ago, the information mentioned may be changed or developed.

    功能:login 页面点击按钮跳转到 chat 页面,对应 login.js 与 chat.js

    login 代码:按钮事件 <Button onPress={() => { console.log(navigate('Chat')) }} title="Sign in" /> login 页面注册路由:StackNavigator({ Chat: {screen: Chat}, Index: {screen: Index}, Login: {screen: Login}, });

    注:navigate 已经通过 const {navigate} = this.props.navigation; 接收, navigate ("chat")返回值一直为 false

    chat.js 代码: import React, {Component} from 'react'; import {SectionList, FlatList, Text, View, StyleSheet, Image,} from 'react-native';

                 export default class Chat extends Component{
                       constructor(props) {
                            super(props)
                        }
                       render() {
                            return (
                                    <View>
                                             <Text>
                                                Profile
                                            </Text>
                                   </View>
                                     )
                                  }
                   }
    

    请问以上有什么错误吗?谢谢了

    1 replies    2018-01-16 23:23:20 +08:00
    aiyov
        1
    aiyov  
    OP
       Jan 16, 2018
    路由所对应的组件也都引入了的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3199 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:54 · PVG 18:54 · LAX 03:54 · JFK 06:54
    ♥ Do have faith in what you're doing.