js 读取上传的json文件内容

时间:2021-08-26 00:08:00   收藏:0   阅读:28
    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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!