作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最佳答案
嘿,德鲁,谢谢你的想法,我自己无法弄清楚,但我认为对于问题中提出的功能来说,你有很多不必要的额外代码。这是我对此的看法,这也同样有效。
export const BottomTabNavigator = createBottomTabNavigator(
{
News: {
screen: NewsNavigator,
navigationOptions: {
tabBarIcon: ({ focused }: any) =>
focused ? <NewsIconActive /> : <NewsIcon />
}
},
Rewards: {
screen: RewardsNavigator,
navigationOptions: {
tabBarIcon: ({ focused }: any) =>
focused ? <RewardsIconActive /> : <RewardsIcon />
}
},
Home: {
screen: HomeNavigator,
navigationOptions: {
tabBarIcon: ({ focused }: any) =>
focused ? <HomeIconActive /> : <HomeIcon />
}
},
Leaderboard: {
screen: LeaderboardNavigator,
navigationOptions: {
tabBarIcon: ({ focused }: any) =>
focused ? <LeaderboardIconActive /> : <LeaderboardIcon />
}
},
Profile: {
screen: ProfileNavigator,
navigationOptions: {
tabBarIcon: ({ focused }: any) =>
focused ? <ProfileIconActive /> : <ProfileIcon />
}
}
},
{
initialRouteName: 'Profile'
},
navigationOptions: ({ navigation }) => ({
tabBarLabel: ({ focused }) => {
const { routeName } = navigation.state;
switch (routeName) {
case 'News':
return focused ? (
<Text>{routeName}</Text>
) : null;
break;
case 'Rewards':
return focused ? (
<Text>{routeName}</Text>
) : null;
break;
case 'Home':
return focused ? (
<Text>{routeName}</Text>
) : null;
break;
case 'Leaderboard':
return focused ? (
<Text >{routeName}</Text>
) : null;
break;
case 'Profile':
return focused ? (
<Text>{routeName}</Text>
) : null;
break;
default:
return null;
break;
}
}
})
}
);
关于reactjs - 如何仅在事件选项卡上显示 TabBar 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49013084/
我是一名优秀的程序员,十分优秀!