1.下载
npm i docx-preview --save
2.引入
var docxx = require("docx-preview");
3.编写容器
<div ref="word"
v-loading="flieLoading"
element-loading-text="拼命加载中"
element-loading-background="#f4f5f7"
element-loading-spinner="el-icon-loading" class="docWrap">
</div>
4.从后端请求到流放进容器
getData() {
this.flieLoading = true;
axios({
url: this.baseUrl + `/${id}/downLoad`,
method: 'post',
data: {},
responseType: "arraybuffer"
}).then(res => {
this.flieLoading = false;
this.$nextTick(() => {
docxx.renderAsync(res.data, this.$refs.word);
})
}).catch((error) => {
this.$message.error(error);
this.flieLoading = false;\
});
},