【问题标题】:Image component uri Cross origin图片组件uri交叉原点
【发布时间】:2017-08-28 07:28:03
【问题描述】:

我想显示来自外部 url 的照片:

<Image
  style={styles /* Some React Native styling */}
  source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
 />

但我收到以下错误:

XMLHttpRequest 无法加载...

【问题讨论】:

  • 你的Image 组件是什么样的?
  • @PaulFitzgerald 是原生 react-vr Image 组件,以上代码为 react-vr 文档示例。但它不起作用
  • 抱歉,刚刚注意到。尝试在网址中将http 替换为https
  • 我猜普通的&lt;img src='https://...' /&gt; 不行,对吧?
  • @lumio 这不是 JSX。这是 react-vr!

标签: javascript reactjs react-native react-360


【解决方案1】:

您需要指定图片的尺寸:

<Image source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
   style={{width: 1, height: 1}} />

这是在文档中引用的:

https://facebook.github.io/react-vr/docs/images.html

https://facebook.github.io/react-native/docs/images.html#network-images

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2016-09-20
    • 1970-01-01
    相关资源
    最近更新 更多