小编Yin*_*raz的帖子

TouchableHighLight onPress里面的map函数反应原生

我有一系列图像,我想在反应原生的组件中显示.
我使用map函数迭代数组并显示它.我还在图像顶部有一个删除按钮.
相关代码是:

      this.state.imgs.map(function(img,i){
        return (
          <View style={{alignItems:'center',justifyContent:'center', height:75, width:75, borderRadius:25}}>
            <Image style={{position:'absolute',resizeMode:'cover', top:0,left:0, borderRadius:38,height:75, width:75, opacity:0.5}} source={{uri: img.path }} />
            <TouchableHighlight onPress={() => this.removeItem(i)}>
              <Image style={{}} source={require('./Images/images_asset65.png')} />
            </TouchableHighlight>
          </View>
          );
      })
Run Code Online (Sandbox Code Playgroud)

问题是TouchableHighlight,我有一个事件,当事件触发时我收到关于"this"的错误(undefined不是函数).
我知道这是一个范围问题,但我无法弄明白.
这里使用箭头功能是否正确?

scope react-native map-function

2
推荐指数
1
解决办法
1461
查看次数

使用 javascript 从 url 获取图像


我试图在我的页面上显示来自不同网址的图像。

<body>
<div id="container">
    <br />

    <canvas width="500px" height="375px" id="canvas">
    </canvas>
    <img src="http://yinoneliraz-001-site1.smarterasp.net/MyPicture.png" />

</div>
<script>

    var img = new Image;
    img.src = "http://yinoneliraz-001-site1.smarterasp.net/MyPicture.png";

    var timer = setInterval(function () { MyTimer() }, 200);
    function MyTimer() {
        var ctx = canvas.getContext('2d');
        ctx.drawImage(img, 0, 0,500,675);
        img = new Image;
        img.src = "http://yinoneliraz-001-site1.smarterasp.net/MyPicture.png";
    }
</script>
Run Code Online (Sandbox Code Playgroud)

另一个站点上的图像每 1.5 秒保存一次。
结果就是看不到图片。
有什么想法吗?

谢谢!

html javascript image

1
推荐指数
1
解决办法
3万
查看次数

标签 统计

html ×1

image ×1

javascript ×1

map-function ×1

react-native ×1

scope ×1