我是react原生的新手。我想从侧边菜单导航到一个屏幕。我已经使用了react-native-navigation Wix V2库。如果有人能帮我举一个简单的例子,我将不胜感激。
发布于 2020-10-12 14:24:40
首先你需要为sideMenu的中心堆栈设置ID。例如:
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
sideMenu: {
right: {
component: {
name: 'SideMenu',
},
},
center: {
stack: {
id: 'STACK_ROOT_ID',
children: [
{
component: {
name: 'Login',
},
},
],
},
},
},
},
});然后,在您的侧边菜单中,您可以像这样在onPress菜单上推送您的注册屏幕。如下所示:
Navigation.push('STACK_ROOT_ID', {
component: {
name: 'REGISTERED_SCREEN_NAME',
options: {
sideMenu: {
right: {
visible: false,
},
},
},
},
});发布于 2019-02-09 20:38:43
react native有一个内置导航,因为它提供了react-native导航(堆栈导航)。因为用户可以很容易地从侧边菜单进行导航
//下面是创建侧边菜单的代码。
const RootDrawer = DrawerNavigator({
demo: { screen: demo },
demo2: { screen: demo2 },
}, {
contentComponent: NavigationDrawer
})
//下面是侧边菜单视图和用于从屏幕导航的链接。
<TouchableOpacity onPress = {() => this.props.navigation.navigate('demo')}>
<View style = {{height: responsiveHeight(8), justifyContent:'center'}}>
<Text style = {{fontSize: responsiveFontSize(2), color: 'black', fontFamily: 'Nunito-Regular', paddingLeft: 30 }} >My Cart</Text>
</View>
</TouchableOpacity>
{this.state.customer &&
<TouchableOpacity onPress = {() => this.props.navigation.navigate('demo1')}>
<View style = {{height: responsiveHeight(8), justifyContent:'center'}}>
<Text style = {{fontSize: responsiveFontSize(2), color: 'black', fontFamily: 'Nunito-Regular', paddingLeft: 30 }} >Account</Text>
</View>
</TouchableOpacity>}
https://stackoverflow.com/questions/54578050
复制相似问题