我搜索並將其與適當的解決方案進行比較沒有看起來錯誤,但我幾乎得到如下所示的錯誤屏幕;react-native-navigation無法導航到另一個頁面
請告訴我錯在這裏航行的代碼;
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import About from './app/components/About';
export default class Home extends Component {
static navigationOptions = {
title: 'Welcome',
};
navigateToAbout(){
const { navigate } = this.props.navigation;
navigate('About')
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={()=>this.navigateToAbout()}>
<Text>Go to About Page</Text>
</TouchableOpacity>
</View>
);
}
}
const SimpleApp = StackNavigator({
Home: { screen: Home },
About: { screen: About },
});
AppRegistry.registerComponent('SimpleApp',() => SimpleApp);
與此相關的可能:https://stackoverflow.com/questions/44538072/react-navigation-onpress自己的功能 – nidaorhan