Answer the question
In order to leave comments, you need to log in
How to remove an element from a Vue object?
I am uploading files to the server with a preview.
imgPreview: [],
form: new Form({
images: []
})
//При выборе картинок вызывается метод
uploadImg(img){
this.form.images = img.target.files;
for(let image of this.form.images){
let reader = new FileReader();
reader.readAsDataURL(image);
reader.onloadend = (image) => {
this.imgPreview.push(reader.result);
}
},
<button type="button" slot="button" @click="deleteImgInArray(index)">удалить</button>
deleteImgInArray(index){
this.$delete(this.form.images,index); //Так не удаляется
this.$delete(this.imgPreview,index);
},
console.log(this.form.images);
FileList {0: File, 1: File, 2: File, 3: File, length: 4}length: 40: File1: File2: File3: File__proto__: FileList
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question