sideMenu在react-native-navigation版本2中不起作用?

问题描述 投票:0回答:1

我是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的文档上没有关于此的任何示例,我搜索了很多内容,但没有找到任何可以帮助我的内容,所以请让我知道我在做错什么,这样我就可以摆脱这个问题

预先感谢!

reactjs react-native react-native-navigation-v2
1个回答
0
投票

[通过将bottomTabs放在层次结构的根sideMenu内而起作用。 sideMenu还具有一个center字段,该字段必需

© www.soinside.com 2019 - 2024. All rights reserved.