Muh*_*kal 2 react-native react-native-vector-icons react-navigation-bottom-tab react-navigation-v5
该图标显示在屏幕/页面中,但不会显示在底部导航中。我尝试过的解决方案:
./gradlew clean
然后尝试过npx react-native run-android
,但结果相同npx react-native link react-native-vector-icons
然后尝试过npx react-native run-android
,但结果相同屏幕截图底部导航栏
屏幕截图设置屏幕
它确实出现在屏幕/页面中,如上面的屏幕截图所示,但不会显示在底部导航中。
注意:我已经在模拟器和真实的 Android 设备中进行了测试,但仍然得到相同的结果!
底部选项卡的代码
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import Ionicons from 'react-native-vector-icons/Ionicons'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import ProductNavigation from './ProductNavigation'
import SettingScreen from '../screen/SettingScreen'
const BottomTab = createBottomTabNavigator();
const BottomTabNav = () => {
return (
<BottomTab.Navigator>
<BottomTab.Screen
name="Home"
component={ProductNavigation}
options={{
tabBarLabel: "Home",
tabBarIcon:({color, size}) => {
<Ionicons name="home-outline" color={color} size={size} />
}}} />
<BottomTab.Screen
name="Settings"
component={SettingScreen}
options={{
tabBarLabel: "Settings",
tabBarIcon: ({color, size}) => {
<Ionicons name="settings-outline" color={color} size={size}
/>
}}} />
</BottomTab.Navigator>
)
}
export default BottomTabNav
const styles = StyleSheet.create({})
Run Code Online (Sandbox Code Playgroud)
实际上问题很简单,你没有从函数中返回任何东西,
tabBarIcon: ({color, size}) => {
//nothing returned here
<Ionicons name="settings-outline" color={color} size={size}
/>
Run Code Online (Sandbox Code Playgroud)
您必须执行此操作,要么使用如下所示的括号,要么使用代码的 return 语句。
tabBarIcon: ({color, size}) => (
<Ionicons name="settings-outline" color={color} size={size}
/>)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3115 次 |
最近记录: |