[英]Not loading Icons from react-native-vector-icons/FontAwesome
[英]React-native fontawesome some icons are not showing
我剛剛添加了 FontAwesome,沒有像本教程這樣的第三方庫,它主要工作,但所有圖標中的一些(大約一半)只是空方塊
那我做錯了什么? 或者 FontAwesome 只是在 React-native 中部分可用?
提前感謝您的幫助
import React, { Component } from 'react';
import { Text, View, Button, AsyncStorage, ScrollView } from 'react-native';
import styles from './../Styles/styles';
render() {
return (
<ScrollView>
<View style={styles.container}>
{...這里還有一些不相關的東西...}
<Text style={{ fontFamily: 'fontawesome', fontSize: 16 }}>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
       
</Text>
</View>
</ScrollView>
);
}
{...}
"rnpm": {
"assets": [
"./assets/fonts/"
]
}
fontawesome.ttf 位於 .\\Projectname\\assets\\fonts\\fontawesome.ttf"
也許為時已晚,但我遇到了同樣的問題。
運行后:
react-native link
這個問題為我解決了。
我在使用庫時遇到了同樣的問題:
import FontAwesome from "react-native-vector-icons/FontAwesome";
... // <setting up bottom tab navigation>
let iconName = "store";
return <FontAwesome name={iconName} size={21} color={tintColor} />
庫中似乎確實缺少許多圖標。 我建議查看./node_modules/react-native-vector-icons/glythmaps/FontAwesome.json
並查看它們是否存在,或者您正在使用的任何庫。 FontAwesome.com 上的名稱不一定反映此庫中的名稱。
例如, tachometer
圖標,在網站上的免費圖標是tachometer-alt
而在這個庫中它是tachometer
。
另一種選擇是使用與react-native-vector-icons
不同的圖標包。 我嘗試了 FontAwesome5 並遇到了類似的問題。
我認為使用https://github.com/FortAwesome/react-native-fontawesome比完全避免使用任何庫更好,因為它允許用戶只導入選定的圖標,而且它基本上只是一堆打包成文件的 svgs .
如果您有許可證,您也可以使用專業字體。
我有一個類似的問題,我無法將image-polaroid
與 expo-fonts 一起使用,並且發現他們最近發布了一個可與 RN(或 Expo)一起使用的官方庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.