<template> <view> <uni-section title="只选择图片" type="line"> <view class="example-body"> <uni-file-picker :autoUpload="false" @select="handleSelect" @delete="handleDelete" limit="9" title="最多选择9张图片"></uni-file-picker> </view> </uni-section> </view></template><script> export default { data() { return { //上传的文件数据,实际的文件数据是tempFiles[i].file tempFiles: [], } }, methods: { handleSelect(data) { //把上传的文件缓存一下 this.tempFiles.push(...data.tempFiles) console.log('上传的图片信息', this.tempFiles); }, handleDelete(data) { console.log(" data.tempFile", data.tempFile); //根据uuid找出要删除的文件index let index = this.tempFiles.findIndex(item => item.uuid === data.tempFile.uuid) if (index !== -1) { //删除对应的缓存文件 this.tempFiles.splice(index, 1) console.log('删除后的图片信息', this.tempFiles); } else { console.log('没有查到对应的文件数据'); } } } }</script><style></style>