Article From:https://segmentfault.com/q/1010000012148644
Question:

The upload component that you do is rendered according to the files array in data. Every time you add a file, you will concat a new file object on the original files array.

The method of chain uploading files is as follows

  function uploadFileList(list, callback) {
    if (list.length) {
      uploadFile(list[0], function() {
        let newList = list.slice(1, list.length)
        uploadFileList(newList, callback)
      })
    } else {
      callback()
    }
    function uploadFile(file, cb) {
    .....
    }

Call time

        this.files = this.files.concat(data)
        uploadFileList(this.files, function() {
            // Multi file serial uploadingThat.uploadNum--})In logic, my uploadFileList method will only be called once, but in the process of uploading.The files array is constantly changing and will be added to the new file object.Ask how to modify to deal with it.

Answer 0:

watch filesThat’s all right. Invocation of new valuesuploadFile
But do not understand the timing of your component upload, is it necessary to manually call to start uploading the first time, and then follow up files, whether or not the tasks in the process are automatically uploaded?

Leave a Reply

Your email address will not be published. Required fields are marked *