React Native 使用精美圖標庫react-native-vector-icons
一、安裝依賴
npm install --save react-native-vector-icons // 下載庫 react-native link react-native-vector-icons // 自動關聯
二、使用
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; import FontAwesome from 'react-native-vector-icons/FontAwesome'; <FontAwesome name={'wpforms'} size={30} color={tintColor} /> <MaterialCommunityIcons name={'face'} size={30} color={tintColor} />
使用說明:
react-native-vector-icons 的圖標分為幾個模塊, 使用的時候先import FontAwesome from 'react-native-vector-icons/FontAwesome';
這樣才能使用 FontAwesome 標簽, 標簽內使用 name 字段指定是某個圖標.
使用的時候可以使用這個網站找到所有圖標的索引:
https://oblador.github.io/react-native-vector-icons/
本博客地址: wukong1688
本文原文地址:https://www.cnblogs.com/wukong1688/p/10860490.html
轉載請著名出處!謝謝~~