我可以将标题传递给图像源吗?

Mal*_*lio 12 react-native

我的图像源是安全的,所以理想情况下我想做以下事情:

<Image source={{uri: "http://path/to/image", 
                headers: {Authorization: 'Bearer ' + this.props.bearerToken}}}/> 
Run Code Online (Sandbox Code Playgroud)

无论如何我可以近似,没有将图像加载到Javascript并从那里渲染图像?

Aun*_*ein 13

React naitve支持在请求图像中添加标题或正文.看到这个.

 <Image source={{
      uri: 'https://facebook.github.io/react/img/logo_og.png',
      method: 'POST',
      headers: {
        Pragma: 'no-cache'
      },
      body: 'Your Body goes here'
    }}
    style={{width: 400, height: 400}} />
Run Code Online (Sandbox Code Playgroud)


Sha*_*ssy 6

此功能最近已合并到React-Native中:https://github.com/facebook/react-native/pull/7338/files