微信小程序图片上传,删除

photographClick: function() {

var that = this;

wx.chooseImage({

count: 9, // 默认9最大一次上传九张

sizeType: [‘original’, ‘compressed’], // 可以指定是原图还是压缩图,默认二者都有

sourceType: [‘album’, ‘camera’], // 可以指定来源是相册还是相机,默认二者都有

success: function(res) {

// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片

that.data.listImg = res.tempFilePaths;

that.data.listImg.map(item => {

that.data.tempFilePaths.push({

Url: item

});

})

that.setData({

tempFilePaths: that.data.tempFilePaths

});

}

})

},

delEteImage: function(e) {

let index = e.target.dataset.index;

this.data.tempFilePaths.splice(index, 1);

this.setData({

tempFilePaths: this.data.tempFilePaths

});

},

关注我更多分享
微信小程序图片上传,删除