首页 文章

世博会应用发布后SVG图像消失

提问于
浏览
2

我正在使用'react-native-remote-svg'在我的本地展示应用程序中显示SVG图像 . 一切都在模拟器/设备上很好地显示,直到我在Expo中发布应用程序,此时所有SVG图像都消失了 .

示例代码:

import Image from 'react-native-remote-svg';
<Image
   style={styling.imageStyle}
   source={require('../res/images/sampleImage.svg')} />

1 回答

  • 1

    您必须预加载它们,因此它们将在 生产环境 版本中可用 .

    _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文件中 .

相关问题