wordToHtml(fileUrl){
console.log('我是在点击的时候实现的,打印fileUrl: ', fileUrl)
let vm=this;
const xhr = new XMLHttpRequest();
xhr.open("get", fileUrl, true);
xhr.responseType = "arraybuffer";
xhr.onload = function () {
if (xhr.status === 200) {
mammoth
.convertToHtml({ arrayBuffer: new Uint8Array(xhr.response) })
.then(function (resultObject) {
vm.$nextTick(() => {
vm.content=resultObject.value;
});
});
}
};
xhr.send();
},
word转html
最新推荐文章于 2025-05-21 11:45:06 发布
这段代码展示了如何使用WordToHtml函数从文件URL获取内容,通过XMLHttpRequest实现异步GET请求,并利用Mammoth将Word文档转换为HTML。它在文件加载成功后更新Vue组件的内容。
7090

被折叠的 条评论
为什么被折叠?



