我是react native的世界中的新手,我想在我的应用程序中从左侧显示侧边菜单,我正在使用react-native-navigation这样做,但是我正面临与此相关的问题
首先,我将导航根设置如下:-
Navigation.setRoot({
root: {
bottomTabs: {
children: [
{
stack: {
children: [
{
component: {
name: "FindPlace",
options: {
bottomTab: {
text: "find place",
icon: response[0],
},
topBar: {
title: {
text: "find place"
},
leftButtons: [
{
icon: response[2],
id: 'leftSideDrawer',
},
],
}
}
}
}
]
}
},
],
},
sideMenu: {
left: {
component: {
name: 'SideDrawer',
id: 'leftSideDrawer'
}
},
},
}
})
我在其中同时声明了bottomTabs和sideMenu,并在findPlace组件上添加了一个触发事件的按钮,在其中我添加了一个Navigation.event()列表器,用于切换我的leftsideMenu的可见性,如下所示:-
constructor(props) {
super(props);
Navigation.events().bindComponent(this)
}
navigationButtonPressed({ buttonId }) {
Navigation.mergeOptions('leftSideDrawer', {
sideMenu: {
left: {
visible: true
}
}
});
}
但是这根本不起作用,它只是显示一个空白屏幕,如果从setRoot中删除sideMenu部分,它将向我显示bottomTab,当我再次添加sideMenu时,它将显示一个空白屏幕。
在RNN版本2的文档上没有关于此的任何示例,我搜索了很多内容,但没有找到任何可以帮助我的内容,所以请让我知道我在做错什么,这样我就可以摆脱这个问题
预先感谢!
[通过将bottomTabs
放在层次结构的根sideMenu
内而起作用。 sideMenu
还具有一个center
字段,该字段必需