图标未显示在 React Native 底部选项卡中
Icons are not displaying in react native bottom tabs
图标未显示在底部选项卡中。我试过从不同的库中放置不同的图标。它显示默认十字框而不是所有图标。
import React from 'react'
import HomeScreen from './Screens/HomeScreen'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { FontAwesome5,Entypo } from '@expo/vector-icons';
import MapScreen from './Screens/MapScreen';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
const Tab = createBottomTabNavigator();
const TabNavigator=()=>{
return (
<Tab.Navigator screenOptions={{
tabBarShowLabel: true,
headerShown:false,
tabBarStyle:{backgroundColor:'#5B8C2A'},
tabBarInactiveTintColor:"#A9A9A9",
tabBarInactiveBackgroundColor:'',
tabBarActiveTintColor:"white",
tabBarActiveBackgroundColor:'#5B8C29',
tabBarHideOnKeyboard:true
}}>
<Tab.Screen name="Home" component={HomeScreen} Options={{
tabBarIcon:({size,color})=>(
<MaterialCommunityIcons name="home" size={size} color={color} />
),
}}/>
<Tab.Screen name="Map" component={MapScreen} Options={{
tabBarIcon:({size,color})=>(
<Entypo name="globe" size={size} color={color} />
)
}}/>
</Tab.Navigator>
);
}
export default TabNavigator
图标未显示在底部选项卡中。我试过从不同的库中放置不同的图标。它显示默认的交叉框而不是所有图标。除此之外,一切正常。甚至导航也能正常工作。
不是Options,是options,小写
图标未显示在底部选项卡中。我试过从不同的库中放置不同的图标。它显示默认十字框而不是所有图标。
import React from 'react'
import HomeScreen from './Screens/HomeScreen'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { FontAwesome5,Entypo } from '@expo/vector-icons';
import MapScreen from './Screens/MapScreen';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
const Tab = createBottomTabNavigator();
const TabNavigator=()=>{
return (
<Tab.Navigator screenOptions={{
tabBarShowLabel: true,
headerShown:false,
tabBarStyle:{backgroundColor:'#5B8C2A'},
tabBarInactiveTintColor:"#A9A9A9",
tabBarInactiveBackgroundColor:'',
tabBarActiveTintColor:"white",
tabBarActiveBackgroundColor:'#5B8C29',
tabBarHideOnKeyboard:true
}}>
<Tab.Screen name="Home" component={HomeScreen} Options={{
tabBarIcon:({size,color})=>(
<MaterialCommunityIcons name="home" size={size} color={color} />
),
}}/>
<Tab.Screen name="Map" component={MapScreen} Options={{
tabBarIcon:({size,color})=>(
<Entypo name="globe" size={size} color={color} />
)
}}/>
</Tab.Navigator>
);
}
export default TabNavigator
图标未显示在底部选项卡中。我试过从不同的库中放置不同的图标。它显示默认的交叉框而不是所有图标。除此之外,一切正常。甚至导航也能正常工作。
不是Options,是options,小写