el-upload 上传.doc(.docx)文件,并读取文件内容

<template>

  <el-upload class="upload-demo" :action="/file/upload/' name="upfile" :show-file-list="false" accept=".docx,.doc" :on-success="(response, file, fileList) => {
                    return handleImgSuccess(response, file, fileList)
                  }
                ">
    <el-button size="small" type="primary">点击上传</el-button>
  </el-upload>
</template>
<script>
import mammoth from "mammoth";
export default {
  data() {
    return {
      inputValue: "",
    };
  },
  methods: {
    handleImgSuccess(response, file, fileList) {
      const arrayBuffer = file.raw;
      mammoth
        .extractRawText({ arrayBuffer: arrayBuffer })
        .then((result) => {
          const text = result.value; // 读取的 .doc 文件内容
          console.log(text);
        })
        .catch((error) => {
          console.error(error);
        });
    },
  },
};
</script>