I have used Font.loadAsync many times but for some reason, I keep getting errors while trying to use it this time.
import React from "react";
I have used Font.loadAsync many times but for some reason, I keep getting errors while trying to use it this time.
import React from "react";
在我的最新项目中,我也在努力学习Font.loadAsync.我决定改用expo-font
模块.您可以在App中初始化此模块.它将加载所有屏幕的字体.
以下是一个示例:
import React from "react";
...
import { useFonts } from "expo-font"; //need to load fonts asynchronously
...
const App = () => {
const [loaded] = useFonts({// function for expo-font
RobotoBlack: FONTS.Roboto-Black.ttf,
RobotoBold: FONTS.Roboto-Bold.ttf,
RobotoRegular:FONTS.RobotoRegular.ttf,
});
if (!loaded) {
return null;
}
...