繁体   English   中英

如何在 react-native 中显示从 api 和 append 到 baseURL 的图像

[英]How to display an image in react-native from an api and append to baseURL

I am trying to display an image in react-native from an api and I want to append the fetched value with the base url which is https://lsm-static-prod.livescore.com/medium but image cannot be seen. 在此处输入图像描述这是代码。 请帮忙

const baseURL = 'https://lsm-static-prod.livescore.com/medium/'

<Image 
   source={baseURL + item.Events[0].T1[0].Img}
             resizeMethod="contain"
             style={{
                     width: 30,
                     height: 30,
                   }}
/>

对于本机反应中的图像:

你应该做

应该像这样提取源:

const uri =`${baseURL}${item.Events[0].T1[0].Img}`

对于 uri,您需要作为source = {{uri:YOUR_URL}}传递

<Image 
   source={{uri:uri}}
             resizeMethod="contain"
             style={{
                     width: 30,
                     height: 30,
                   }}
/>

希望它有效:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM