【发布时间】:2021-03-04 23:17:57
【问题描述】:
之前一切正常,但没有图标显示为带有 X 的框,我收到此错误:
fontFamily "FontAwesome" is not a system font and has not been loaded through Font.loadAsync.
- If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.
- If this is a custom font, be sure to load it with Font.loadAsync.
package.json
"dependencies": {
"@expo/ngrok": "^2.4.3",
"@expo/vector-icons": "^12.0.3",
"@react-native-community/cli": "^4.14.0",
"@react-native-community/datetimepicker": "^3.0.9",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/bottom-tabs": "^5.11.3",
"expo": "^40.0.1",
"expo-cli": "4.2.1",
"expo-font": "^9.0.0",
"expo-status-bar": "~1.0.3",
"firebase": "^8.2.9",
"moment": "^2.29.1",
"ngrok": "^3.4.0",
"npm": "^7.5.4",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "0.63.4",
"react-native-check-box": "^2.1.7",
"react-native-elements": "^3.1.0",
"react-native-gesture-handler": "^1.10.0",
"react-native-paper": "^4.7.1",
"react-native-reanimated": "^1.13.2",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.17.1",
"react-native-unimodules": "^0.12.0",
"react-native-vector-icons": "^8.1.0",
"react-native-web": "~0.13.12",
"react-navigation": "^4.4.3",
"react-navigation-stack": "^2.10.2",
"react-navigation-tabs": "^2.10.1"
},
请帮忙!这个错误快把我逼疯了!
【问题讨论】:
-
您如何使用 FontAwesome?如果我没记错的话 FontAwesome 有 npm 包,但我在你的 package.json 中没有看到它
-
@garjted 我只是像
import { FontAwesome5 } from '@expo/vector-icons';一样导入它,然后我把图标像<FontAwesome5 style={{marginLeft: 19}} name="file-invoice" size={32} color="black" />一样放入。这些图标以前可以使用,我从来不需要将 font awesome 下载到 package.json 中。
标签: react-native expo vector-icons