在React Native中,我需要从一个屏幕导航到另一个屏幕。但是我不理解这个概念。所以,我做了如下的事情,
在App.js中
'Series' object has no attribute 'month'
文件夹其他屏幕位于文件夹./src/Login Screen / index.js
在App.js中单击“入门”按钮后,我需要导航到登录屏幕
答案 0 :(得分:3)
应用程序的条目是App.js,它已导入index.ios.js
index.ios.js
import React, { Component } from 'react';
import {
AppRegistry
} from 'react-native';
import App from './component/stackScreens/App';
AppRegistry.registerComponent('reactNav', () => App);
在App.js中,将导入StackNavigator。 App.js是一个堆栈,其中包含导航所需的所有组件。
App.js
import React from 'react';
import { StackNavigator } from 'react-navigation';
import ScreenOne from './ScreenOne';
import ScreenTwo from './ScreenTwo';
import ScreenThree from './ScreenThree';
const App = StackNavigator({
ScreenOne: { screen: ScreenOne},
ScreenTwo: { screen: ScreenTwo},
ScreenThree: {screen: ScreenThree}
})
export default App;
ScreenOne.js
class ScreenOne extends Component {
render() {
const { navigate } = this.props.navigation
return (
<View style={styles.container}>
<TouchableHighlight
onPress={() => navigate("ScreenTwo")}
style={styles.button}>
<Text
style={styles.buttonText}>Screen One </Text>
</TouchableHighlight>
</View>
);
}
};
const {导航} = this.props.navigation:将屏幕指定为 导航。