react-native - 从需要 header 的 URL react native 图像

标签 react-native http-headers request-headers

我需要显示一个 Image 组件,其中源是一个 URL,需要传递 http header 才能获取它(用于身份验证目的)。

这如何在 RN 中实现?

有没有办法将标题添加到源中?

最佳答案

这已添加到 react-native。看这里:

https://reactnative.dev/docs/images.html#network-requests-for-images

链接示例:

<Image
  source={{
    uri: 'https://reactjs.org/logo-og.png',
    method: 'POST',
    headers: {
      Pragma: 'no-cache',
    },
    body: 'Your Body goes here',
  }}
  style={{width: 400, height: 400}}
/>

关于react-native - 从需要 header 的 URL react native 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60711802/

相关文章:

android - React Native 中的 facebook.react.uimanager.ViewGroupDrawingOrderHelper.getChildDrawingOrder 中的 java.lang.ArrayIndexOutOfBoundsException

javascript - 我不明白如何使用它或它的作用,来自带有屏幕的 React Native Expo 默认项目的 _loadResourcesAsync

http - 使用 X-Robot-Tag 而不是 robots.txt 有什么优势吗?

go - Http Over TLS Golang 未接收 header

Android - Volley 库 : Session expired issue in SSL production environment

带有凭据的 jQuery CORS 仅适用于 Chrome

reactjs - 通过在内部调用 navigation.navigate() 来制作共享组件 - React Native

integration-testing - 如何设置 react-native 集成测试

rest - 如何将基本 HTTP 身份验证与 REST Web 服务 (Java+Jersey) 结合使用?

HTTP 内容长度小于文件字节大小,是否已完全下载?