学无先后,达者为师

网站首页 编程语言 正文

readAsText 读取本地文件

作者:茶荼 更新时间: 2021-12-27 编程语言
<el-upload class="upload-demo"
                       action="#"
                       :on-change="handleChange"
                       :file-list="fileList"
                       :limit="3"
                       :on-exceed="handleExceed">
              <el-button size="small"
                         type="primary">上传文件</el-button>
            </el-upload>
handleChange (file) {
      let reader = new FileReader();
      if (typeof FileReader === "undefined") {
        this.$message({
          type: "info",
          message: "您的浏览器不支持文件读取。"
        });
        return;
      }
      reader.readAsText(file.raw, "utf-8");
      var _this = this;
      reader.onload = function (e) {
        _this.textInfo = e.target.result;
        console.log('textInfo', _this.textInfo)
      };
    },

原文链接:https://blog.csdn.net/qq_34414994/article/details/121516049

栏目分类
最近更新