图像组件uri Cross origin

时间:2017-08-28 07:28:04

标签: javascript reactjs react-native react-360

我想要显示来自外部网址的照片:

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

但是我收到以下错误:

XMLHttpRequest无法加载...

1 个答案:

答案 0 :(得分:0)

您需要指定图片的尺寸:

<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