意外的类型编号在世博会 Web 中出现 URI 字符串错误



我正在Expo Web上开发一个React Native应用程序。我正在尝试按照世博会文档中关于加载自定义字体的说明加载自定义字体。但是我Unexpected type number expected a URI string or Asset from expo-asset得到错误.我已经在网上搜索过,但没有提到这个问题的解决方案。

state = { fontLoaded: false };
async componentDidMount() {
try {
await Font.loadAsync({
Merriweather: require('./assets/fonts/Merriweather.ttf')
});
this.setState({ fontLoaded: true });
} catch (e) {console.log(e); }
};

详见 https://snack.expo.io/@uahnbu/romee

我通过将require替换为import或创建一个选择路径的新对象来解决fonts[key].default

最新更新