index.vue 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. <template>
  2. <div id="container" style="width: 100%;height: 100vh">
  3. </div>
  4. </template>
  5. <script>
  6. import axios from 'axios'
  7. import { defaultOptions, renderAsync } from "docx-preview";
  8. export default {
  9. mounted(){
  10. console.log(this.$route.query.file)
  11. if(this.$route.query && this.$route.query.file){
  12. axios.get(this.$route.query.file, {responseType: 'blob'}).then(res => {
  13. renderAsync(res.data, document.getElementById("container"), null, {
  14. className: "docx", // 默认和文档样式类的类名/前缀
  15. inWrapper: true, // 启用围绕文档内容渲染包装器
  16. ignoreWidth: false, // 禁止页面渲染宽度
  17. ignoreHeight: false, // 禁止页面渲染高度
  18. ignoreFonts: false, // 禁止字体渲染
  19. breakPages: true, // 在分页符上启用分页
  20. ignoreLastRenderedPageBreak: true,//禁用lastRenderedPageBreak元素的分页
  21. experimental: false, //启用实验性功能(制表符停止计算)
  22. trimXmlDeclaration: true, //如果为真,xml声明将在解析之前从xml文档中删除
  23. debug: false, // 启用额外的日志记录
  24. }
  25. );
  26. })
  27. }
  28. }
  29. }
  30. </script>