Android网络资源图像上的React-native无法加载

时间:2018-03-30 07:44:35

标签: android react-native

我的Android操作系统是5.1,React-natvie是0.50.1,我根据官方网站教程设置它,但它没用了

<View style={styles.container}>
    <Image style={{width:300, height:300}} 
    source={{url: 'https://example.com/image.jpg'}} />
    <Text>hello world</Text>
  </View>

它只显示你好世界

3 个答案:

答案 0 :(得分:1)

将其更改为img.onload = function (e) { newcanvas.save(); newcanvas.beginPath(); newcanvas.moveTo(last - (18 / 100 * bheight), totheight + (38 / 100 * bheight)); newcanvas.arc(last - (18 / 100 * bheight), totheight + (38 / 100 * bheight), (last + (14 / 100 * bheight)) - (last - (28 / 100 * bheight)) - 1, 0, 2 * Math.PI); newcanvas.strokeStyle = "#fff"; newcanvas.stroke(); newcanvas.clip(); newcanvas.drawImage(img,last - (18 / 100 * bheight)-(1.5/100*canvas.width),totheight + (38 / 100 * bheight)-(1.5/100*canvas.width)); newcanvas.restore(); // lv.image=""; } ,您已使用uri

url

答案 1 :(得分:0)

  1. 检查Android清单是否添加此权限:

    机器人:名称= “android.permission.INTERNET对”

  2. 更新您的代码:

  3. <View style={styles.container}>
            <Image style={{width:300, height:300}} 
            source={{uri: 'https://example.com/image.jpg'}} />
            <Text>hello world</Text>
          </View>

答案 2 :(得分:0)

使用uri代替url

<View style={styles.container}>
<Image style={{width:300, height:300}} 
source={{uri: 'https://example.com/image.jpg'}} />
<Text>hello world</Text>

相关问题