我正在使用博览会的原生基本模板
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
关于如何解决这个问题有什么想法吗?
此警告表明您尝试在 Expo 项目中使用的 Courier 字体在设备上不可用,并且您尚未使用
expo-font
将其包含为自定义字体。如果您遇到此问题,可以通过以下方式解决:
expo-font
:npx expo install expo-font
import * 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();
}, []);