示例中:react-native版本0.66.4   react-native-vector-icons版本9.2.0

1、安装$ npm install --save react-native-vector-icons

2、在文件android\app\build.gradle中添加如下代码

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

3、自动配置$ react-native link  react-native-vector-icons

如果报错,使用$ npx react-native link  react-native-vector-icons

4、这样就可以在代码中使用图标了

import { StyleSheet, Text, View, SafeAreaView } from 'react-native'

import React from 'react'

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

const App = () => {

return (

)

}

export default App

const styles = StyleSheet.create({})

 5、重新启动项目,效果

6、图标查询地址https://oblador.github.io/react-native-vector-icons/ 

 

好文链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: