我正在尝试为登录界面设置导航,尝试重新链接依赖项和重新安装包,但只修改了两个文件。我正在MacOS上工作并在iOS 13.5上进行模拟。
App.js
import React, { Component } from 'react'
import {
StyleSheet,
View
} from 'react-native'
import Mystack from './navigators/StackNavigator'
export default class App extends Component {
render() {
return (
<NavigationContainer>
<Mystack/>
</NavigationContainer>
)
}}
const styles = StyleSheet.create({
container: {
},
})
以及StackNavigator.js
import * as React from 'react';
import { createStackNavigator} from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
import LogIn from './src/components/LogIn.js'
import SignUp from './src/components/SignUp.js'
import Dashboard from './src/components/Dashboard.js'
const Stack = createStackNavigator();
function Mystack() {
return(
<Stack.Navigator initialRouteName = "LogIn"
screenOptions = {{
headerTitleAlign: 'center',
HeaderStyle: {
backgroundColor: "#FFF700",
},
headerTintColor: '#FFF',
headerTitleStyle: {
fontWeight: 'bold',
},
}}>
<Stack.Screen name = "LogIn"
component = {LogIn}
options = {{
title: 'LogIn',
headerShown: false
}}/>
<Stack.Screen name = "SignUp"
component = {SignUp}
options = {{
title: 'SignUp',
headerShown: false
}}/>
<Stack.Screen name = "Dashboard"
component = {Dashboard}
options = {{
title: 'Dashboard'
}
}/>
</Stack.Navigator>
)
}
export default Mystack;