Cam*_*ega 5 ios react-native native-base expo
我正在使用 expo 的本机基本模板expo-template-native-base,启动 iOS 模拟器时出现错误
fontFamily "Courier" 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.
at node_modules/expo-font/build/Font.js:27:16 in processFontFamily
at node_modules/react-native/Libraries/ReactNative/renderApplication.js:54:4 in renderApplication
at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:117:25 in runnables.appKey.run
at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:213:4 in runApplication
Run Code Online (Sandbox Code Playgroud)
有想法该怎么解决这个吗?
此警告表明您尝试在 Expo 项目中使用的 Courier 字体在设备上不可用,并且您尚未使用expo-font. 如果您遇到此问题,可以通过以下方式修复:
expo-font:npx expo install expo-fontimport * as Font from 'expo-font';
import { useEffect } from "react";
const loadFonts = async () => {
await Font.loadAsync({
Courier: require('./fonts/Courier.ttf'), // Replace with path
});
};
useEffect(() => {
loadFonts();
}, []);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1308 次 |
| 最近记录: |