<el-upload
          action=""
          class="upload-demo"
          ref="upload"
          :on-change="handleChange"
          :auto-upload="false"
          :limit="1"
        >
    handleChange(file) {
      let reader = new FileReader();
      if (typeof FileReader === "undefined") {
        this.$message({
          type: "info",
          message: "您的浏览器不支持文件读取。"
        });
        return;
      }
      reader.readAsText(file.raw, "gb2312");
      var _this = this;
      reader.onload = function(e) {
        _this.textInfo = e.target.result;
      };
}

如果是乱码,则说明编码有问题,通过reader.readAsText(file.raw, "gb2312");自行设置

Logo

前往低代码交流专区

更多推荐