Invalid problem with vue.js deleting preview picture.

vue.js rookie, is trying to do a multi-image preview delete and upload function, has achieved a single image upload preview, deletion also encountered some problems, I hope Daniel guide the confusion, attach the html,vue.js code.
main problem: when selecting multiple image previews, only a single image is displayed. When deleting a single image, I don"t know how to get the index of the picture. I have tried to use vmurfort, but adding vMuffor = "(key,image) in images" image preview in < div class= "col-sm-10" > is not successful
html:

.
            <div class="form-group">
                <div class="col-sm-2 control-label"></div>
                <div class="col-sm-10">
                    <img src="image" id="pic" style="height: 267px; width: 267px;"/>
                    <a href="-sharp"
                            style="position: absolute;" @click="delImage(key)"> 
                            <span class="glyphicon glyphicon-remove"></span>
                    </a>
                    <button @click="removeImage"></button>
                    <button @click="uploadImage"></button>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-2 control-label"></div>
                <div class="col-sm-10">
                <input type="file" id="uploadFile" name="uploadFile" @change="onFileChange" multiple="multiple" class="form-control" >
                </div>
            </div>

vue.js:

    onFileChange(e) {
        var files = e.target.files || e.dataTransfer.files;
        if (!files.length)
        return; 
        this.createImage(files);
    },
    createImage(file) {
        var image = new Image();         
        var vm = this;
        var leng=file.length;
        for(var i=0;i<leng;iPP){
            var reader = new FileReader();
            var uploadFile  = document.getElementById("uploadFile").files[0];
            reader.readAsDataURL(uploadFile);
            reader.onload =function(e){
                  $("-sharppic").attr("src", e.target.result);
            };                 
        }
    },
    delImage:function(index){
        this.images.shift(index);
        
    },
    removeImage: function(e) {

/ / this.images = [];

        $("-sharppic").remove();
    },
Mar.07,2021

1. First create a global variable to store information about the picture.

this.imgs = [];

2. In the createImage () method, set imgs each time you select a picture.

for () {
  this.imgs.push({
    file: files[i],
    dataUrl: e.target.result
  });
}

-this step can be done, and then it will be easy. -

3. For example, to preview all the pictures.

<div v-for="img in imgs">
  <img />
  <button />
</div>

4. For example, delete a picture.

removeImg(index) {
  this.imgs.splice(index, 1);
}

5. Finally, upload it as a whole.

let formData = new FormData();
this.imgs.forEach((img, i) => {
  formData.appendData('img' + i, img);
});

it was so detailed upstairs that I had to find some questions

  1. it's best not to mix vue and jquery
  2. what the heck is shift (index)? it should be splice (index,1)
Menu