微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

react-native Avatar 元素为 uri 属性添加授权标头

如何解决react-native Avatar 元素为 uri 属性添加授权标头

我使用的是 react-native 版本:“0.63.4”。在 Avatar react-native url 中,我设置了 url 值,但是,我需要附加一个带有 url 的授权标头。有人可以建议我该怎么做吗?

import {ListItem,Avatar} from 'react-native-elements'
    const CustomListItem = ({id,profilePicture}) => {
        return (
            <ListItem key={id} bottomDivider>
    <ListItem bottomDivider>
                <Avatar rounded 
                 source={{uri:'https://test.url/'+profilePicture}}/>
    
       </ListItem>
        )
    }
export default CustomListItem

解决方法

Avatar 的 source 道具基于 React Native 组件的 ImageSource

enter image description here

所以,在react native的官方文档中,你可以像这样自定义网络请求图片:(从文档中复制)

<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 }}
/>

此处有更多详细信息:Network Requests for Images

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。