项目中用的elementui上传照片墙的图片组件,跟后端联调之后,后端返回给我的url是一个字符串,传多张图需要我自己将每个字符串拼接起来,那我做删除操作的时候怎么删除这个拼接的字符串呢,怎么知道当前选的是哪个,要删哪个?
上传方法我用的是自定义的方式
uploadImage (e, res) {
let _this = this;
let reader = new FileReader();
reader.readAsDataURL(e.file);//读文件,为base64
reader.onload = function(){
_this.imageName = e.file.name;
_this.imageData = reader.result.substring(reader.result.indexOf(",") + 1);//切除“data:image/png;base64,”
API.uploadImage({
imageName: _this.imageName,
imageData: _this.imageData,
}).then(response => {
if (response.success) {
_this.form.imageList.push(response.response);
_this.form.roUploadImageUrls = _this.form.imageList.join(',');
_this.$message.success('图片上传成功!');
}
})
};
}
elementui的删除方法
//删除缩略图
handleRemove(file, fileList) {
},
加载详情的时候,可以把后端传过来的image的字符串存起来,可以转成数组
移除的时候找到这个url,删除掉