操作步骤:
- 安装npm install --save react-native-vector-icons
- 配置(android ),在 android/app/build.gradle 文件下添加以下代码
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
- 使用
import Icon from 'react-native-vector-icons/FontAwesome';
<Icon name="rocket" size={30} color="#900" />;
报错:
- 最后发现所有的问题都出在了不对应上。
- 导入文件要与使用的 icon name 对应。 (oblador.github.io/react-nativ…
import Icon from 'react-native-vector-icons/AntDesign';
<Icon name="stepforward" size={30} color="#900" />;
- 把对应的字体包引入
如果不写以下配置,则需要手动把react-native-vector-icons的Font文件中相应的包拷贝到项目的 android/app/src/main/assets/fonts 目录下。
project.ext.vectoricons = [
iconFontNames: [ 'AntDesign.ttf' ]
]