我正在使用“react-native-remote-svg”在我的 React Native Expo 应用程序中显示 SVG 图像。一切都在模拟器/设备上显示得很好,直到我在 Expo 中发布应用程序,此时所有 SVG 图像都消失了。
示例代码:
import Image from 'react-native-remote-svg';
<Image
style={styling.imageStyle}
source={require('../res/images/sampleImage.svg')} />
最佳答案
您必须预加载它们,以便它们在生产版本中可用。
_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 文件中。
关于react-native - Expo 应用程序发布后 SVG 图像消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49477063/