React native 内置后不会显示图像
我正在显示类别及其图像。我从后端获取类别,它还返回url。在开发者模式下,emülatör(android)显示类别图像,但当我尝试使用npm build(react native run android——variant release)构建时,图像没有显示。我确信分类数据即将到来。图片来自s3存储桶,我将它们全部公开,但仍然没有更改。找不到解决办法。显示npm运行android,但不是在构建之后React native 内置后不会显示图像,react-native,React Native,我正在显示类别及其图像。我从后端获取类别,它还返回url。在开发者模式下,emülatör(android)显示类别图像,但当我尝试使用npm build(react native run android——variant release)构建时,图像没有显示。我确信分类数据即将到来。图片来自s3存储桶,我将它们全部公开,但仍然没有更改。找不到解决办法。显示npm运行android,但不是在构建之后 <View style={{ borderColor:turkuazColor,borde
<View style={{ borderColor:turkuazColor,borderStyle:"solid",borderWidth: 1,backgroundColor: whiteColor, width: width / 5, height: width / 5, alignItems: "center", justifyContent: "center", borderRadius: 99 }}>
<Image source={{uri : img.uri}} resizeMode="contain" style={{ width: width / 6.5, height: width / 8.5, alignSelf: "center", marginBottom: 5 }} />
</View>
所以,我们找到了一个解决方案。在s3中,启用了静态网站托管,我试图从该url获取图像,但是在开发人员模式下,它可以工作,但在构建之后无法工作。我开始使用s3 bucket的url,它不同于静态托管url 静态主机在url中有区域信息,如“us-east-3”。还添加了CORS配置
*
邮递
得到
放
删除
头
*
现在一切都好了
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>