【问题标题】:React Native Image component not render image from external url on iOS 14React Native Image 组件不会在 iOS 14 上从外部 url 渲染图像
【发布时间】:2020-07-28 16:33:38
【问题描述】:

我升级到 iOS 14 + XCode-beta 版本 12 beta 3,从那一刻起,React Native Image 组件不再从外部 URL 渲染图像。在 Android 上,Image 组件仍然可以完美运行。

这是我如何调用图像的代码。

const avatarImageUrl = Config.IMAGE_BASE_URL + this.props.data.avatar;

<Image source={{uri: avatarImageUrl}} style={styles.avatarImage}/>

这是我的配置组件:

export default Config = {
    API_BASE_URL: 'link-to-api',
    IMAGE_BASE_URL: 'link-to-api',
    
    // date when Realm database is updated with fresh API data and 
    bundled with app
    BUILD_DATE: '2020-06-18',
};

和样式

avatarImage: {
    flex: 3,
    width: '100%',
    height: '100%',
    borderTopLeftRadius: 10,
    borderTopRightRadius: 10,
    backgroundColor: '#cccccc',
    width: "100%",
    marginLeft: 0,
    marginRight: 0,
  },

有没有人在 iOS14 上对 React Native 有同样的问题?

谢谢

罗伯特

【问题讨论】:

  • 可以分享一下样式吗?
  • @İlker 现在在编辑后的帖子中。

标签: image react-native ios14


【解决方案1】:

你可以尝试几件事:

A.使用以下包通过运行来解决问题:

npm install --save react-native-fix-image

npx react-native-fix-image

然后重建项目。

注意:每次重新安装 node_modules 后,您都必须运行 npx react-native-fix-image

B.将 react-native 升级到 V0.63.2 然后重建项目。

我使用了解决方案 A。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多