![ea919b5eccdc169047850e4e0e9e700a.png](https://i-blog.csdnimg.cn/blog_migrate/e7f4e121f76fd22538448ec92f0f2811.jpeg)
在React-Native开发中少不了使用图标,接下来看看怎样在项目中使用图标
项目图标地址:
React-native-vector-icons图标github地址github.com![a0e4a2b0b487fcf52deec6d71b128aae.png](https://i-blog.csdnimg.cn/blog_migrate/8451a5823bf89b51cf761f259f630184.jpeg)
你可以看文档,也可以看这篇文章都可以完成使用设置(仅供android参考,ios请移步上面文档)
> 1. 安装react-native-vector-icons图标库
yarn add react-native-vector-icons
> 2. 使用命令使其与之关联
react-native link
***以上步骤完成之后一定要 react-native run-android 重新安装,不然不生效或者显示 xx之类的 ***
> 3. 使用图标
import React, { Component, Fragment } from 'react';
import {
View,
Text
} from 'react-native';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import AntDesign from 'react-native-vector-icons/AntDesign';
export default class Popular extends Component{
render(){
return (<Fragment>
<View>
<Text>Popular</Text>
<MaterialIcons
name={'whatshot'}
size={26}
/>
<View><Text>-----------------------------------</Text></View>
<AntDesign
name={'clockcircle'}
size={26}
/>
</View>
</Fragment>);
}
}
上面的MaterialIcons 就是下面的黑色框标注的名字,你需要那个模块的就引入那个模块
![6c7061ad68f196e26b30a880e3a150dc.png](https://i-blog.csdnimg.cn/blog_migrate/1e888d65136054a5fc8fe73bff32edce.png)
在手机上的效果:
![bf6da371c14edb7b737ef39215a605ba.png](https://i-blog.csdnimg.cn/blog_migrate/ffe426bbc2341aec6a9cd0c319c52d3a.jpeg)
以上就是使用react-native-vector-icons的android使用效果
focusdroid/ReactNative_testProjectgithub.com![3f5232cc0ded53a4aa3062de07f4459b.png](https://i-blog.csdnimg.cn/blog_migrate/5e2493d8bed6c1253abeeeadc5999fbe.jpeg)