我尝试从 api 获取 URI 图像,但它引发了以下错误:
我一直在寻找此信息,但找不到像我这样的案例
它不显示图像,但如果它通过数据
这是我的api:
{
"Home": [
{ "id": "1",
"LinkHome":"https://telesistema11.com.do/tn-deportes/futbol/la-quinta-jornada-de-la-ldf-iniciara-este-proximo-jueves",
"URLHome":"{uri: 'https://telesistema11.com.do/storage/app/uploads/public/609/b45/eab/thumb_46456_932_582_0_0_crop.jpeg'}"
}
],
"TSTA": [
{ "id": "1",
"LinkTSTA":"",
"URLTSTA":""
}
],
"Radio": [
{ "id": "1",
"LinkRadio":"",
"URLRadio":""
}
]
}
这是我的代码:
function Getdatajson(){
const [isLoading, setLoading] = useState(true);
const [data, setData] = useState([]);
useEffect(() => {
fetch('http://72.44.48.164/wp-content/themes/tn/json/PublicidadTeleStream.json')
.then((response) => response.json())
.then((json) => setData(json.Home))
.catch((error) => console.error(error))
.finally(() => setLoading(false));
}, []);
return (
<View style ={styles.bannerHome}>
{isLoading ? <ActivityIndicator/> : (
<FlatList
data={data}
keyExtractor={({ id }, index) => id}
renderItem={({ item }) => (
<TouchableOpacity style={{backgroundColor:'red'}} onPress={()=>
Linking.openURL("item.LinkHome")
}>
<Image
style={styles.imgad}
source={item.URLHome}
/>
</TouchableOpacity>
)}
/>
)}
</View>
)
}
我是原生反应的新手,所以我不知道问题是什么 请我需要帮助。