react-native - react-navigation TabNavigator点击按钮不切换,滑动可以切换
本文介绍了react-native - react-navigation TabNavigator点击按钮不切换,滑动可以切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
1.:swipeEnabled: true,这样可以滑动切换,点击item不能切换
2:swipeEnabled: false,这样滑动和点击都不能切换
需求是点击切换,问题出在哪里,各位大神帮忙看看
const Tabs = TabNavigator({
Newest: {
screen: Newest,
navigationOptions: {
tabBarLabel:'首页',
tabBarIcon:({tintColor}) => (<Image source={require('./image/find.png')} style={[{tintColor: tintColor},styles.icon]}/>),
},
},
Coming: {
screen: Coming,
navigationOptions: {
tabBarLabel:'热门',
tabBarIcon:({tintColor}) => (<Image source={require('./image/find.png')} style={[{tintColor: tintColor},styles.icon]}/>),
}
},
Search: {
screen: Search,
navigationOptions: {
tabBarLabel:'搜索',
tabBarIcon:({tintColor}) => (<Image source={require('./image/find.png')} style={[{tintColor: tintColor},styles.icon]}/>),
}
}
}, {
trueinitialRouteName:Search,
animationEnabled: false, // 切换页面时是否有动画效果
tabBarPosition: 'bottom', // 显示在底端,android 默认是显示在页面顶端的
swipeEnabled: true, // 是否可以左右滑动切换tab
backBehavior: 'none', // 按 back 键是否跳转到第一个Tab(首页), none 为不跳转
tabBarOptions: {
activeTintColor: '#47aaff', // 文字和图片选中颜色
inactiveTintColor: '#000', // 文字和图片未选中颜色
showIcon: true, // android 默认不显示 icon, 需要设置为 true 才会显示
indicatorStyle: {
height: 0 // 如TabBar下面显示有一条线,可以设高度为0后隐藏
},
style: {
backgroundColor: '#fff', // TabBar 背景色
height: 50,
},
labelStyle: {
fontSize: 12, // 文字大小,
margin:0,
},
},
pressColor:'material',
});
解决方案
测试机系统升级,但是android的相应版本工具没有下载,更新到一致就好了
这篇关于react-native - react-navigation TabNavigator点击按钮不切换,滑动可以切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文