【发布时间】:2021-04-17 00:50:25
【问题描述】:
我正在尝试在使用 expo 的 react-native 应用程序上使用 Ionicons,不幸的是该图标未显示并且收到以下错误:
fontFamily "ionicons" 不是系统字体,尚未通过 Font.loadAsync 加载。
如果您打算使用系统字体,请确保您输入的名称正确且受您的设备操作系统支持。
如果这是自定义字体,请务必使用 Font.loadAsync 加载它。
我正在通过以下方式使用 Iocincons:
import { Ionicons } from '@expo/vector-icons';
....
<Ionicons name="arrow-back" size={24} color="black" />
另外,这是我的 package.json 文件:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@expo/vector-icons": "^12.0.4",
"@react-native-community/masked-view": "^0.1.10",
"axios": "^0.21.1",
"expo": "~40.0.0",
"expo-app-loading": "^1.0.1",
"expo-font": "^9.0.0",
"expo-status-bar": "~1.0.3",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.0.1",
"react-native-screens": "^2.18.1",
"react-native-web": "~0.13.12",
"react-navigation": "^4.4.4",
"react-navigation-header-buttons": "^7.0.0",
"react-navigation-stack": "^2.10.4",
"react-redux": "^7.2.3",
"redux": "^4.0.5"
},
"devDependencies": {
"@babel/core": "^7.13.15"
},
"private": true
}
我已经尝试删除 node_modules、package-lock.json 并运行 npm install,但并没有解决问题。
任何想法都会受到赞赏。
【问题讨论】:
-
在你的代码中,你有没有写过这样的地方——
fontFamily: "ionicons"? -
不,我在上面提供的示例中使用了 Ionicons。 @KartikeyVaish
标签: react-native expo ionicons