首页 > 解决方案 > 来自(http)的反应本机图像在发布到.apk后不会出现

问题描述

react native image from uri (http) 可以在调试过程中出现,但在发布到 apk 并安装在 android 手机上后不会出现。

<Image
      source={{uri: props.img}} //props.img value is 'http://example.jpg'
      style={{
        flex: 1,
        height: undefined,
        width: undefined,
        resizeMode: 'cover',
        borderRadius: 10,
        marginTop: 12,
      }}
/>

标签: androidreact-nativehttpreact-native-android

解决方案


在 AndroidManifest.xml 中添加这个

<application
    ...
    android:usesCleartextTraffic="true"
    ...>
    ...
</application>

推荐阅读