react-native - 转到子场景选项卡 - react-native-router-flux
问题描述
这是我的路由器层次结构:
<Tabs
key='tabbar'
backToInitial
onTabOnPress={() => {
console.log('Back to initial and also print this');
}}
swipeEnabled
hideNavBar={true}
>
<Scene
title='Profilo'
key='profile'
component={Profile}
tabBarLabel='Profilo'
icon={TabBarIcon}
name='ios-person'
titleStyle={{
fontFamily: 'RobotoRegular',
fontSize: 24,
color: '#00b0ff'
}}
>
<Scene
title='adsf'
key='vehicle'
component={Vehicle}
titleStyle={{
fontFamily: 'RobotoRegular',
fontSize: 24,
color: '#00b0ff'
}}
/>
</Scene>
</Tabs>
如果我在Profilo
页面上并且我不会转到该Vehicle
页面,我会使用Actions.vehicle()
但我收到此错误:
Actions.vehicle() 不是函数
我已经尝试过这个解决方案,但这也不起作用我该如何解决这个问题?
解决方案
使用动作场景键将要求您的场景与您的其他场景处于同一级别,即vehicle
场景不能是profile
.
此外,您将需要一个Stack
组件来容纳profile
和vehicle
场景,以便您可以调用Actions.{key}
以正确访问场景。
我在这里放了一份小吃供你玩。:)
建议的解决方案:
<Tabs
key='tabbar'
backToInitial
onTabOnPress={() => {
console.log('Back to initial and also print this');
}}
swipeEnabled
hideNavBar={true}
>
<Stack
title='ProfiloStack'
key='profileStack'
>
<Scene
title='Profilo'
key='profile'
component={Profile}
tabBarLabel='Profilo'
icon={TabBarIcon}
name='ios-person'
titleStyle={{
fontFamily: 'RobotoRegular',
fontSize: 24,
color: '#00b0ff'
}}
/>
<Scene
title='adsf'
key='vehicle'
component={Vehicle}
titleStyle={{
fontFamily: 'RobotoRegular',
fontSize: 24,
color: '#00b0ff'
}}
/>
</Stack>
</Tabs>
推荐阅读
- kubernetes - 使用 API 在 k8s 上部署 custom_resource_definition
- symfony - Symfony 注释目录在 prod 环境中非常大
- xaml - 您能否在 UWP XAML 中定义一个厚度静态资源,该资源引用另一个静态资源(双精度)作为其值之一?
- r-markdown - 如何在 RMarkdown 中包含 Bibtex 参考?
- python - 使用 Python 将 CSV infile 更改写入 CSV outfile
- laravel - 初始化 DB:Laravel 存储库模式中的事务
- python - Python CVXPY kronecker 产品尺寸
- pdf - 如何在浏览器中打开 pdf 而不是在 webapi 中下载
- php - 尝试将函数添加到已经存在的 PHP 库
- windows - 如何使用通配符对目录中的文件进行计数?