<van-uploader capture="{{capture}}" max-count="1" file-list="{{ fileList }}" deletable="{{ true }}" bind:delete="delete" bind:after-read="afterRead" accept="media" />
//上传预览
afterRead(event) {
const { file } = event.detail;
let array = {
url: "",
name: ""
};
array.url = file.url;
array.name = 'test/' + String((new
Date().getTime())).split('').reverse().join('') + '.' + file.url.substring(file.url.lastIndexOf('.') + 1);
this.data.fileList.push(array);
this.data.piclist.push(file.url);
this.setData({
fileList: this.data.fileList
})
console.log(this.data.fileList)
},
//删除
delete(event) {
let list = this.data.fileList;
list.splice(event.detail.index, 1);
this.setData({
fileList: list
})
},
微信小程序使用van-uploader实现图片上传、预览与删除
最新推荐文章于 2024-03-26 19:00:00 发布