react-native-vector-icons:使用FontAwesome

时间:2017-04-20 10:20:22

标签: react-native font-awesome

我正在尝试使用此库react-native-vector-icons在我的react-native应用中使用FontAwesome图标。我已经按照安装过程(npm install,link,更新我的gradle.properties ......) 然后在我的代码中我导入了这样的图标:

const Icon = require('react-native-vector-icons/FontAwesome');

我在渲染方法中使用它:

<Button>
  <Icon name='home' />                        
</Button>

不幸的是,在运行时,这会出现这个错误:

enter image description here

如何在我的本机应用程序中使用Fontawesome图标?

感谢您的帮助

1 个答案:

答案 0 :(得分:4)

您必须改为使用import

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

相关问题