需注意this指向变化问题

import SparkMD5 from 'spark-md5'
    handleChangePackage (file, fileList) {
      this.packageList = []
      this.packageList = fileList
      const _this = this
      const fileReader = new FileReader()
      const dataFile = file.raw
      const spark = new SparkMD5.ArrayBuffer()
      fileReader.readAsArrayBuffer(dataFile)
      fileReader.onload = function (e) {
        spark.append(e.target.result)
        const md5 = spark.end()
        _this.softwareForm.md5 = md5
      }
    },

 

posted on 2022-04-20 15:51  蓝蓝蓝蓝HZ  阅读(110)  评论(0编辑  收藏  举报