首先在data定义一个存放图片的数组
例:img[]
然后在wxml 用wx.for循环出img的数据即可
scImg:
function () {
var that =
this;
wx.chooseImage({
count:
6,
success:
function (res) {
var tempFilePaths = res.tempFilePaths;
var imgList = that.data.img;
for (
var i
in tempFilePaths){
imgList.push(tempFilePaths[i])
}
that.setData({
img: imgList
})
}
})
},
delImg:
function (e) {
var index = e.currentTarget.dataset.index;
var Img =
this.data.img;
var that =
this;
wx.showModal({
title:
'提示',
content:
'确定要删除此商品吗?',
success:
function (res) {
if (res.confirm) {
console.log(
'用户点击确定')
Img.splice(index,
1);
}
else
if (res.cancel) {
return
false
console.log(
'用户点击取消')
}
that.setData({
img: Img
});
}
})
},