elementui图片的上传与删除思路

elementui图片的上传与删除思路_第1张图片



file-list是数组的形式

export default{
	data(){
	addForm:{
	files:[{name:'xxx.jpg',url:'xxx.jpg'},{name:'xxx2.jpg',url:'xxx.2jpg'}]
	}
	}
}

上传成功方法,采用数组合并的思路

uploadSuccess(response, file, fileList){
      			let files = {name:response,url:response};
      			this.addForm.files.push(files);
      		}

删除图片的方法

handleRemove:function(file, fileList) {
	      	    for (var i in this.addForm.files) {
	            	for (var k in this.addForm.files[i]) {
	                   if (this.addForm.files[i][k] == file.uid) {
	                       delete this.addForm.files[i];
	                    break;
	                	}
	            	}
	      		}
      		},

你可能感兴趣的:(VUE,elementui)