图片可以多选不会覆盖只会叠加
js:
Page({
/**
* 页面的初始数据
*/
data: {
imagePathImage:[],
videotrue:false
},
//选择图片
handleChooseAlbumImage:function(){
//系统APi,让用户在相册中选择图片(或者拍照)
var that = this;
wx.chooseImage({
//count: 2,
success:function(res){
console.log(res);
//1:取出路径
const path = res.tempFilePaths;
//多个路径tempFilePaths
const pathold = that.data.imagePathImage;
for(var i=0;i<pathold.length;i++){
path.push(pathold[i]);
}
//2:设置imagePath
that.setData({
imagePathImage: path
})
}
})
}
)}
wxml:
<!--图片-->
<!--show-menu-by-longpress:开启长按图片显示识别小程序码菜单(二维码或者发送给朋友)-->
<block wx:for="{{imagePathImage}}" wx:for-item="item" wx:for-key="index">
<image show-menu-by-longpress="{{true}}" src="{{item}}"></image>
</block>
<button bindtap="handleChooseAlbumImage">选中图片</button>