我正在尝试使用在expo文档中找到的代码。我已经包含了我沉思的图像和字体,而它在离子线字体上显示出奇怪的错误,如预期的那样。虽然它是正确的。我找不到有什么问题?
function cacheImages(images) {
return images.map(image => {
if (typeof image === 'string') {
return Image.prefetch(image);
} else {
return Asset.fromModule(image).downloadAsync();
}
});
}
function cacheFonts(fonts) {
return fonts.map(font => Font.loadAsync(font));
}
export default class App extends React.Component {
constructor() {
super();
this.state = {
isReady: false,
store: configureStore(() => this.setState({ isLoading: false })),
mainApplication: false,
};
}
async _loadAssetsAsync() {
const imageAssets = cacheImages([
require("./assets/icons/app.png"),
require("./assets/icons/loading.png"),
require("./img/img1.jpg"),
require("./img/img2.jpg"),
require("./img/img3.jpg"),
]);
const fontAssets = cacheFonts([
Ionicons: require("@expo/vector-icons/fonts/Ionicons.ttf"),
Arial: require("native-base/Fonts/Roboto.ttf"),
Roboto: require("native-base/Fonts/Roboto.ttf"),
Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),]);
await Promise.all([...imageAssets, ...fontAssets]);
}
render() {
if (!this.state.isReady) {
return (
<AppLoading
startAsync={this._loadAssetsAsync}
onFinish={() => this.setState({ isReady: true })}
onError={console.warn}
/>
);
}
else {
return (
return <Provider store={this.state.store}>
<Root>
<Nav/>
</Root>
</Provider>;
);
}
}
此代码有什么问题,我该如何解决?
答案 0 :(得分:0)
这些步骤可以帮助您解决问题:
react-native-vector-icons
是否为依赖项,如果存在则将其删除npm install @expo/vector-icons --save
node_modules
文件夹并再次运行npm install