StackNavigation不能跳转。求助!!!!



  • 请高人指点一下,我在view里面加了一个button,想通过button+Stacknavigation跳转到另一个页面,点击button没反应。



  • @zhangtengfei91 import React,{Component} from 'react';
    import {
    View,
    Text,
    Button
    }from 'react-native';
    import FruitScreen from './FruitScreen'
    import {StackNavigator} from 'react-navigation'

    export default class TabScreen1 extends Component {
    //const {navigate} =this.props.navigation;
    render() {
    const {navigate} =this.props.navigation;
    return (
    <View style={{flex:1,justifyContent:'center',backgroundColor:'red',alignItems:'center'}}>
    <Button onPress={()=>navigate('Fruit')} title='TabScreen1'/>

            </View>
        )
    }
    

    }

    const Fruit1 = StackNavigator({
    TabScreen1:{screen:TabScreen1},
    Fruit:{screen:FruitScreen}
    })



  • onPress={()=>{ navigation.navigate('Fruit'); }}试一试