element el-upload选择并读取txt文本内容

vue yekong 1344℃

html

          <el-upload action="#" accept=".txt" :on-change="handleChangeUpload" :auto-upload="false">
            <div class="liulan">浏览</div>
          </el-upload>

js

    handleChangeUpload(file, fileList) {
      var reader = new FileReader();
      console.log(file)
      reader.readAsText(file.raw, "UTF-8");
      reader.onload = function (e) {
        const val = e.target.result;
        console.log(val)
      }
    },
喜欢 (2)