【问题标题】:Icons are not showing in navbar导航栏中未显示图标
【发布时间】:2021-03-25 20:53:38
【问题描述】:

嗨,这是我创建的导航栏,我使用一些图标在我按下它们时在屏幕之间导航,这些图标在我的 expo 项目中看起来很好(没有 Android 和 ios 文件夹)

这是我的代码:

import * as React from 'react';
import { Text, View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import EmptyHistory from '../Accueil/EmptyHistory.js'
import Profile from '../Accueil/Profile.js'
import Accueil from '../Accueil/Accueil.js';

const Tab = createMaterialBottomTabNavigator();

function MyTabs() {
    return (
        <Tab.Navigator
            barStyle={{ backgroundColor: '#FFFFFF' }}
            initialRouteName="Accueil"
            activeColor="#D05A0B"
            
            
        >
            <Tab.Screen
                name="Historique"
                component={EmptyHistory}
                options={{
                    tabBarLabel: 'Historique',
                    tabBarIcon: ({ color }) => (
                        <MaterialCommunityIcons name="history" color={color} size={26} />
                    ),
                }}
            />
            <Tab.Screen
                name="Accueil"
                component={Accueil}
                options={{
                    tabBarLabel: 'Accueil',
                    tabBarIcon: ({ color }) => (
                        <MaterialCommunityIcons name="food" color={color} size={26} />
                    ),
                }}
            />
            <Tab.Screen
                name="Profile"
                component={Profile}
                options={{
                    tabBarLabel: 'Profile',
                    tabBarIcon: ({ color }) => (
                        <MaterialCommunityIcons name="account" color={color} size={26} />
                    ),
                }}
            />
        </Tab.Navigator>
    );
}

export default function Navbar() {
    return (
        <NavigationContainer>
            <MyTabs/>
        </NavigationContainer>
    );
}

所以我使用 npx react-native(带有 Android 和 ios 文件夹)切换了我的项目,我完成了所有安装,包括矢量图标

但结果不一样,我的图标在我的导航栏中没有正确显示

有什么解决办法吗?

【问题讨论】:

  • 我猜你正在使用'react-native-vector-icons',你链接你的图书馆了吗?尝试 react-native 链接

标签: node.js react-native expo


【解决方案1】:

在裸React Native中安装图标与在React Native中添加新字体一样,所以你可以关注这个https://mehrankhandev.medium.com/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4

【讨论】:

    猜你喜欢
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    • 1970-01-01
    相关资源
    最近更新 更多