我正在做一个像登录/注册应用程序这样的练习项目,我正在使用 react-navigations 中的 Stack Navigation,它运行良好,
现在,当用户登录时,他应该被重定向到仪表板屏幕,我希望在标题右侧有一个抽屉“我还添加了一个屏幕截图”,并且我也在堆栈导航中创建了仪表板屏幕我不知道如何添加堆栈导航中的那个抽屉我只想在我的仪表板屏幕上使用抽屉,所以任何人都可以提供帮助 谢谢
App.js(我在其中添加了所有堆栈屏幕)
import React from 'react';
import { createStackNavigator, createDrawerNavigator } from 'react-navigation';
import HomeScreen from './screens/HomeScreen';
import LoginScreen from './screens/LoginScreen';
import RegisterScreen from './screens/RegisterScreen';
import Dashboard from './screens/Dashboard';
const StackNavigation = createStackNavigator({
HomeStack: HomeScreen,
LoginStack: LoginScreen,
RegisterStack: RegisterScreen,
DashboardStack: Dashboard,
}, {
initialRouteName: 'HomeStack',
});
const DrawerNav = createDrawerNavigator({
DashboardStack: Dashboard,
})
export default class App extends React.Component {
render() {
return (
<StackNavigation />
);
}
}
仪表板.js
import React from 'react';
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
export default class Dashboard extends React.Component {
static navigationOptions = {
headerTitle: 'Dashboard',
headerLeft: null,
headerTitleStyle: {
flex: 1,
color: '#fff',
textAlign: 'center',
alignSelf: 'center',
fontWeight: 'normal',
},
headerStyle: {
backgroundColor: '#b5259e',
},
}