小程序中图片点击预览、长按转发、保存、识别图中二维码

<view wx:for="{{imgalist}}"wx:for-item="image"class="previewimg">  
  <image src="{{image}}" data-src="{{image}}" data-index="{{index}}" bindtap="previewImage" class='img'></image>  
</view>  
  data: {
    imgalist: ['https://www.cslpyx.com/weiH5/jrx.jpg', 'https://www.cslpyx.com/weiH5/mmd.jpg'],
  },
 previewImage: function (e) {
    let that=this;
    let index = e.currentTarget.dataset.index;
    wx.previewImage({
      current: this.data.imgalist[index], // 当前显示图片的http链接   
      urls: this.data.imgalist // 需要预览的图片http链接列表   
    })  
    wx.getImageInfo({// 获取图片信息(此处可不要)
      src: 'https://www.cslpyx.com/weiH5/jrkj.jpg',
      success: function (res) {
        console.log(res.width)
        console.log(res.height)
      }
    })
    
  }

小程序文档:https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewImage.html

转载地址:https://blog.csdn.net/csl125/article/details/79085597/

如果有帮到你的话,欢迎激励一下作者。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值