【发布时间】:2022-11-11 08:54:55
【问题描述】:
我正在使用 React Native 开发一个移动应用程序,并在其中使用 Tab.Navigator - Tab.Screen 组件。在导航器中,我使用初始路由名称,选项卡栏选项, 和屏幕选项特性。其他属性中一切正常,直到 javaScript 找到屏幕选项.然后它给了我警报:
// Place the following in 'screenOptions' in your code to keep current behavior:
{
"tabBarStyle": [
{
"display": "flex"
},
null
]
}
有关详细信息,请参阅https://reactnavigation.org/docs/bottom-tab-navigator#options。
我已经在我的代码中做到了:
const App = () => {
return (
<>
<NavigationContainer>
<Tab.Navigator
initialRouteName='ExerciseScreensStack'
tabBarOptions={{
tabBarActiveTintColor: '#efb810',
tabBarInactiveTintColor: 'black'
}}
screenOptions = {({ route }) =>({
tabBarStyle: [
{
display: "flex"
},
null
],
tabBarIcon: ({ color }) =>
screenOptions(route, color),
})}
>
这是当我在其中一个屏幕上时呈现图标颜色的功能:
const screenOptions = (route, color ) =>{
let IconName;
switch (route.name){
case 'Home':
IconName = "home-circle-outline"
break;
case "ExerciseScreensStack":
IconName = "basketball"
break;
case 'RoutinesStack':
IconName = "walk"
break;
}
return(
<Icon type='material-community' name={IconName} size={22}
color={color}/>
); }
我仍然有同样的问题。我应该怎么做才能修复它?我应该忽略它,因为它不会间接影响应用程序的性能吗?为什么会这样?
【问题讨论】:
-
请发布整个代码 sn-p 即您的导航器设置和相关的选项卡屏幕。
-
我刚刚用与我相关的所有内容更新了帖子。知道为什么会这样吗?
标签: react-native react-native-tabnavigator