简体   繁体   English

反应本机使用矢量图标

[英]React native use vector icons

Im having trouble using icons from react-native-vector-icons package. 我在使用react-native-vector-icons包中的图标时遇到了麻烦。

Here is how i import: 这是我的导入方式:

import MaterialIcon from 'react-native-vector-icons/dist/MaterialCommunityIcons';
import FoundationIcon from 'react-native-vector-icons/dist/Foundation';

Here is how i use: 这是我的用法:

<BottomNavigation
              labelColor="white"
              rippleColor="white"
              style={{ height: 56, elevation: 8, position: 'absolute', left: 0, bottom: 0, right: 0 }}
              onTabChange={(newTabIndex) => {return} }
              >
                <Tab
                barBackgroundColor="#37474F"
                label="Movies & TV"
                icon={<MaterialIcon size={24} color="white" name="tv" />}
                />
                <Tab
                barBackgroundColor="#00796B"
                label="Music"
                icon={<FoundationIcon size={24} color="white" name="music" />}
                />
                <Tab
                barBackgroundColor="#5D4037"
                label="Books"
                icon={<FoundationIcon size={24} color="white" name="books" />}
                />
            </BottomNavigation>

Behaviour is: icons are displaying, but the wrong icons. 行为是:正在显示图标,但是图标错误。 Material displays as japanese symbol, Foundation as a square with an X in the middle. 材质显示为日文符号,粉底显示为中间带有X的正方形。

How to correctly import and use those icons? 如何正确导入和使用这些图标?

in my projects I'm using the import as: 在我的项目中,我将导入方式用作:

import Icon from 'react-native-vector-icons/Ionicons'

So try just import as: 因此,尝试仅导入为:

import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
import FoundationIcon from 'react-native-vector-icons/Foundation';

Sorry, can't comment 'cause of rep, hope it works. 抱歉,无法评论“代表的原因,希望它有用。

我需要手动链接依赖项并重建项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用带有 react-native-vector-icons 的材质社区图标 - How to use material community icons with react-native-vector-icons 不从 react-native-vector-icons/FontAwesome 加载图标 - Not loading Icons from react-native-vector-icons/FontAwesome 图标未正确加载react-native-vector-icons - Icons not loading correctly react-native-vector-icons 如何在反应原生矢量图标中从多个文件导入图标? - How to import icons from multiple files in react native vector icons? 用故事书中的反应原生矢量图标反应原生 web 问题 - React native web issue with react native vector icons in storybook 如何在一个文件中使用不同的字体(多个)react-native-vector-icons? - How to use different fonts (more than one) of react-native-vector-icons in one file? 无法在 React Native 中使用 Font Awesome 图标 - unable to use Font Awesome Icons in React Native React-native 与故事书问题 react-native-vector-icons 和 react-native-paper - React-native with storybook problem react-native-vector-icons and react-native-paper 添加反应原生矢量图标以使用反应原生 web 反应原生时出错 - Error while adding react native vector icons to react native with react native web BottomNavigation在React Native中不显示@ expo / vector-icons - BottomNavigation does not show @expo/vector-icons in React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM