如果im在组件挂载时在我的app.js中加载图像和字体,然后路由到另一个页面,我需要做什么特殊的事情才能调用这些缓存的图像?或者我只是使用,例如:
<ImageBackground
source={require('../assets/images/backgrounds/sky.jpg')}
style={styles.backgroundContainer}
>
app.js为:
async _loadAssetsAsync() {
try {
await cacheAssetsAsync({
images: [require('./assets/images/backgrounds/sky.jpg')],
fonts: [
FontAwesome.font,
{ 'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf') },
],
});
} catch (e) {
console.warn(
'There was an error caching assets (see: main.js), perhaps due to a ' +
'network timeout, so we skipped caching. Reload the app to try again.'
);
console.log(e.message);
} finally {
this.setState({ appIsReady: true });
}
}
发布于 2019-05-17 10:09:59
如果在app.json
中包含了assetBundlePatterns
,则不需要缓存图像。这些图片将被捆绑到应用程序中。
...
"assetBundlePatterns": [
"**/*"
],
...
https://stackoverflow.com/questions/56177603
复制相似问题