本文介绍了Expo App 发布后 SVG 图像消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用react-native-remote-svg"在我的 react native expo 应用程序中显示 SVG 图像.一切都在模拟器/设备上很好地显示,直到我在 Expo 中发布应用程序,此时所有 SVG 图像都消失了.
I am using 'react-native-remote-svg' to display SVG images in my react native expo app. Everything displays nicely on simulators/devices until I publish the app in Expo, at this point all SVG images disappear.
示例代码:
import Image from 'react-native-remote-svg';
<Image
style={styling.imageStyle}
source={require('../res/images/sampleImage.svg')} />
推荐答案
您必须预加载它们,这样它们才能在生产构建中使用.
You have to preload them, so they will be available in production build.
_loadResourcesAsync = async () => {
return Promise.all([
Asset.loadAsync([
require('./assets/svg/some.svg')
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Ionicons.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free
// to remove this if you are not using it in your app
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
}),
]);
};
在您的 expo 项目的 App.js 文件中.
In your App.js file of expo project.
这篇关于Expo App 发布后 SVG 图像消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!