1.下包
//预览docx文件
npm install @vue-office/docx vue-demi
//如果是vue2.6版本或以下还需要额外安装 @vue/composition-api
2.引入
<template>
<div>
//在src填入文档地址
<VueOfficeDocx src='http://...../xx.docx' style="width:80%" @rendered="rendered" ></VueOfficeDocx>
</div>
</template>
<script>
import VueOfficeDocx from '@vue-office/docx'
import '@vue-office/docx/lib/index.css'
export default {
name: 'myPreview',
components: {
VueOfficeDocx
},
data () {
return {
}
},
methods: {
rendered () {
console.log(666)
}
}
}
</script>
<style lang='scss' scoped>
</style>