从需要标题的URL响应本机图像 [英] React Native image from URL that requires headers
本文介绍了从需要标题的URL响应本机图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要显示一个 Image
组件,其中的来源是一个URL,该URL要求传递HTTP标头来获取它(出于身份验证的目的).
I need to display an Image
component where the source is a URL that requires http headers passed on to fetch it (for authentication purposes).
这如何在RN中实现?
是否可以将标头添加到源中?
Is there a way to add headers to the source?
推荐答案
已添加到react-native.看到这里:
This has been added to react-native. See here:
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}}
/>
这篇关于从需要标题的URL响应本机图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文