js 读取上传的json文件内容

    getActionData (file) {
      const __this = this
      var reader = new FileReader()// 新建一个FileReader
      reader.readAsText(file, 'UTF-8')// 读取文件
      reader.onload = function (evt) { // 读取完文件之后会回来这里
        var fileString = evt.target.result // 读取文件内容
        const jsonObj = JSON.parse(fileString)
        __this.actData[file.uid] = jsonObj.animations
        console.log('fileString..', jsonObj, jsonObj.animations, Object.keys(jsonObj.animations))
      }
    },
原文地址:https://www.cnblogs.com/dhjy123/p/15186736.html