reactjs - 如何使用本机反应在选项卡之外导航?
问题描述
我想从标签屏幕内部导航到另一个屏幕。
我的问题是我无法在选项卡之外导航。
当我按下花朵图像导航到我的登录屏幕时,登录屏幕会在当前选项卡内打开!
这是我的堆栈导航器。该项目包含选项卡导航
import { createAppContainer, createStackNavigator, createDrawerNavigator } from 'react-navigation';
const AppStackNavigator = createStackNavigator({
Login: Login,
Developer: Developer,
Projects: Projects,
},
{
headerMode: 'none',
navigationOptions: {
headerVisible: false,
}
});
这是我的标签导航器屏幕:
const TabNavigator = createMaterialTopTabNavigator({
Photo: {
screen: check_note_type2,
navigationOptions: {
tabBarIcon: (<Image
style={{resizeMode:'contain', width: wp('4%'), height: hp('5%'), tintColor: '#bfb288' }}
source={require('../assets/photo.png')} />)
}
},
Voice: {
screen: check_note_type3,
navigationOptions: {
tabBarIcon: (<Image
style={{ resizeMode:'contain',width: wp('4%'), height: hp('5%'), tintColor: '#bfb288' }}
source={require('../assets/voice.png')} />)
}
},
Text: {
screen: check_note_type4,
navigationOptions: {
tabBarIcon: (<Image
style={{ resizeMode:'contain',width: hp('4%'), height: hp('5%'), tintColor: '#bfb288' }}
source={require('../assets/note.png')} />)
}
},
解决方案
在这种情况下,您可以通过 react-navigation 提供的 API 在组件外部使用导航道具:
https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html
推荐阅读
- python - 我如何实际验证给定 url 的 SSL 证书?
- css - 在标题元素上使用剪辑路径时,z 索引不适用于图像
- swift - 迅速。将字符串中的百分比编码符号转换为它们的 ascii 表示
- command-line-interface - 使用 GAM 创建保管库事项和导出邮箱
- tkinter - 如何将变量除以数字?
- python - 如何实现自定义编码 Tensorflow Federated
- mfc - 如何从 CMFCRibbonComboBox 更改字体
- haskell - 为什么Data.Bitraversable中没有traverse1和traverse2?
- r - 删除某些行后,R 中的类从 data.frame 更改为字符
- mysql - 如何在 SQL 的 WHERE 条件中使用 AVG()?