直接是文件路径:https://127.0.1.1/filePath.docx
页面:
引入插件:npm i jszip
npm i docx-preview
方法:
seeDocx(file_url) { let xhr = new XMLHttpRequest(); xhr.open("get", file_url, true); xhr.responseType = "blob"; let that = this//onload this指向为window中转一下 xhr.onload = function () { if (this.status === 200) { docx.renderAsync(xhr.response, that.$refs.preview); } }; xhr.send(); },