js 导入本地word解析

import mammoth from "mammoth";
import marked from 'marked'
 created() {
    let vm=this;
    const xhr = new XMLHttpRequest();
    xhr.open("get", "/src/page/kolApply/agree.docx", true);  //  获取word路径
    xhr.responseType = "arraybuffer";
    xhr.onload = function () {
      if (xhr.status == 200) {
        mammoth
          .convertToMarkdown({ arrayBuffer: new Uint8Array(xhr.response) })
          .then(function (resultObject) {
            vm.$nextTick(() => {
              vm.wordHtml=marked(resultObject.value)
              console.log(resultObject.value)
            });
          });
      }
    };
    xhr.send();
  },

你可能感兴趣的:(web前端开发,vue,导入word,js导入word,html导入word)