我需要显示一个 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/