react-native - Expo 应用程序发布后 SVG 图像消失

标签 react-native svg expo

我正在使用“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/

相关文章:

android - 错误 : <identifier> expected with package com. native

javascript - toSVG() 不尊重文本和下划线的来源

android - 使用 expo-image-picker 选择图像时应用程序崩溃

javascript - 选择模板时出现 Expo 错误 : Could not get npm url for package

javascript - 在 React hooks 中我们还需要功能性的 setState 方式吗?

javascript - 如何在 TypeScript 中使用 navigation.replace?

react-native - 如何将 React-Native App 导出为 Android 库 (.aar)?

svg - 填充规则 ="evenodd"如何在星形 SVG 上工作

css - svg css 圆 Angular 不起作用

reactjs - 从 React Native 登录 Google 时出现 TypeError - Expo