react-native-router-flux tabbar not displayed
问题描述:
我在显示react-native-router-flux中的tabbar时遇到了问题。react-native-router-flux tabbar not displayed
我创造了这样的场景。我能够显示标签栏的第一个标签,但无法使标签栏显示在底部。谢谢你的帮助。
const scenes = Actions.create(
<Scene key='root' tabs={true} unmountScenes
component={connect(stateToProps)(Switch)}
selector={props => props.isLoggedIn ? 'tabBar' : 'login'}>
<Scene key='splash' component={Splash} title=''
hideNavBar={false} />
<Scene key='login' component={Login} title=''
hideNavBar={true} />
<Scene key='signup' component={Signup} title='Signup'
hideNavBar={false} />
<Scene key="tabBar" tabs icon={TabbarIcon} tabBarStyle={styles.tabBarStyle}>
<Scene key='home' component={Home} title='Home' initial={true}
icon={TabbarIcon} />
<Scene key='diary' component={Diary} title='Diary'
icon={TabbarIcon} />
<Scene key='cabinet' component={Cabinet} title='Cabinet'
icon={TabbarIcon} />
</Scene>
</Scene>
);
更新:由于我解决了问题,因此已关闭。感谢您的帮助。
答
您应该从任何场景移除tabs
财产,但tabBar
。也请从tabBar
删除icon
属性场景。其他一切似乎都很好。
这应该工作:
const scenes = Actions.create(
<Scene key='root' unmountScenes
component={connect(stateToProps)(Switch)}
selector={props => props.isLoggedIn ? 'tabBar' : 'login'}>
<Scene key='splash' component={Splash} title=''
hideNavBar={false} />
<Scene key='login' component={Login} title=''
hideNavBar={true} />
<Scene key='signup' component={Signup} title='Signup'
hideNavBar={false} />
<Scene key="tabBar" tabs tabBarStyle={styles.tabBarStyle}>
<Scene key='home' component={Home} title='Home' initial={true}
icon={TabbarIcon} />
<Scene key='diary' component={Diary} title='Diary'
icon={TabbarIcon} />
<Scene key='cabinet' component={Cabinet} title='Cabinet'
icon={TabbarIcon} />
</Scene>
</Scene>
);
感谢尤金你回答,我想下面的代码,但我得到了一个错误,“一个场景的关键‘的TabBar’不存在。”。我认为这是因为我们从场景'root'中删除'tabs'属性。我试着把它放回去,它运行良好,但我仍然无法找到标签栏。 –
据我所知,有孩子的场景不应该有“组件”属性。尽管你的根场景确实如此。也许这是问题? –
感谢@EugeneZinin的努力。我发现是什么导致了这个问题,这是因为我没有在'场景'声明的顶部声明类'TabbarIcon'。我仍然在调整从编译语言到脚本语言,所以我忘了这个基本的东西。无论如何,谢谢你。 –