我安装这个库:
npm install react-native-vector-icons
并链接它
react native link
我将它导入到我的项目中
import Icon from 'react-native-vector-icons/Ionicons'
然后我在组件的渲染部分中使用它,如下所示:
<Icon name={'ios-person-outline'} />
但是当我运行 android 应用程序时没有错误但图标是一个问题图标
任何 body 有想法?
最佳答案
当我开始使用 react-native-vector-icons 直到我了解不同类型的组件时,我曾经遇到过类似的问题。
type="AntDesign"
type="Entypo"
type="FontAwesome"
type="FontAwesome5"
type="FontAwesome5Brands"
type="Foundation"
type="Ionicons"
type="MaterialCommunityIcons"
type="MaterialIcons"
type="SimpleLineIcons"
type="Octicons"
等等...图标名称“person-outline”可以在“https://oblador.github.io/react-native-vector-icons/”的“MaterialIcons”下找到,所以我们可以这样做;
<Icon name='person-outline' type="MaterialIcons" />
希望这个解释有帮助。注意:确保您采取初始步骤;
npm install react-native-vector-icons --save
和react-native link react-native-vector-icons
关于react-native - React Native 中 "react-native-vector-icons"的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53464015/