axios中文件下载
let loading = this.$common.loading("正在上传");
      let form = new FormData();
      let headers = {
        responseType: "blob"
      };
      form.append("file", e.file);
      this.$axios
        .post(e.action, form, headers)
        .then(res => {
          loading.close();
          let _this = this;
          let reader = new FileReader();
          reader.readAsText(res, "utf-8");
          reader.onload = function() {
            try {
              let a = JSON.parse(this.result);
              let b = a.data.totel;
              let c = b.split(",");
              _this.$message.success(
                `总共${c[0]}条, 成功${c[1]}条, 重复${c[2]}条(数据库中已存在))`
              );
            } catch (error) {
              let blob = new Blob([res]);
              let objectUrl = URL.createObjectURL(blob);
              let a = document.createElement("a");
              a.href = objectUrl;
              a.download = "错误样本.xls";
              //下面这个写法兼容火狐
              a.dispatchEvent(
                new MouseEvent("click", {
                  bubbles: true,
                  cancelable: true,
                  view: window
                })
              );
              window.URL.revokeObjectURL(blob);
            }
          };reponseType设为blob后如何校验是否正确与否
let reader = new FileReader();
          reader.readAsText(res, "utf-8");
          reader.onload = function() {
            try {
              let a = JSON.parse(this.result);
              let b = a.data.totel;
              let c = b.split(",");
              _this.$message.success(
                `总共${c[0]}条, 成功${c[1]}条, 重复${c[2]}条(数据库中已存在))`
              );
            } catch (error) {
              let blob = new Blob([res]);
              let objectUrl = URL.createObjectURL(blob);
              let a = document.createElement("a");
              a.href = objectUrl;
              a.download = "错误样本.xls";
              //下面这个写法兼容火狐
              a.dispatchEvent(
                new MouseEvent("click", {
                  bubbles: true,
                  cancelable: true,
                  view: window
                })
              );
              window.URL.revokeObjectURL(blob);
            }
        }    axios中设置了response:blol后,如何处理json对象
原文:https://www.cnblogs.com/chendada/p/12210377.html