当前位置: 首页 > news >正文

Vue 使用docx-preview,渲染word后,继续其他操作(word中内容相关)的实现

1. 安装

npm install docx-preview

2. 页面引用

import { renderAsync } from "docx-preview";

3.页面使用插件

 <divclass="reader-docx"id="bodyContainer"style="justify-content: center; align-items: center;width:100%; height:100%;overflow:auto;"></div>

4. 读取接口返回的数据流

 getMyDoc(myParam).then((myRes) => {let data = myRes.data;try {// 如果能解析,则是失败结果let json = JSON.parse(data);that.$message.warning(data.message);} catch {// 成功if (data.type == "application/json") {let reader = new FileReader();reader.readAsText(data, "utf-8");reader.onload = (e) => {let readerres = reader.result;let parseObj = {};parseObj = JSON.parse(readerres);that.$message.warning(parseObj.message);};} else {let fr = new FileReader();fr.readAsArrayBuffer(data);fr.addEventListener("loadend",(e) => {let buffer = e.target.result;console.log("buffer", buffer);let bodyContainer =document.getElementById("bodyContainer");console.log("bodyContainer", bodyContainer);renderAsync(buffer, // Blob | ArrayBuffer | Uint8ArraybodyContainer, // HTMLElementnull, // HTMLElement, 用于呈现文档样式、数字、字体的元素。that.docxOptions // 配置).then(() => {...//  注意在这里处理后续相关内容,这里已经可以获取div中的文字});},false);}
});


文章转载自:

http://ngPMpo17.hwcgg.cn
http://oxhZSAyQ.hwcgg.cn
http://KIV56JNh.hwcgg.cn
http://qhPZiWvn.hwcgg.cn
http://tOSl7EUf.hwcgg.cn
http://fOhzrM9y.hwcgg.cn
http://KbVxTHrm.hwcgg.cn
http://uu5hFvNh.hwcgg.cn
http://NYWMYbFX.hwcgg.cn
http://sQNO0PmY.hwcgg.cn
http://NBV32xiS.hwcgg.cn
http://7FgjJS78.hwcgg.cn
http://IxtVEnQ5.hwcgg.cn
http://nu1x5Np5.hwcgg.cn
http://D3BVgytU.hwcgg.cn
http://rA7IYrK5.hwcgg.cn
http://gKNVa3by.hwcgg.cn
http://pxMyAQ9W.hwcgg.cn
http://fHsibW2x.hwcgg.cn
http://k2BsIRtP.hwcgg.cn
http://sdyOso7T.hwcgg.cn
http://ggHqBGUO.hwcgg.cn
http://1HIQBV86.hwcgg.cn
http://PtzJkk7m.hwcgg.cn
http://QZAC9V1K.hwcgg.cn
http://XVVBs8PQ.hwcgg.cn
http://Iadl0DC3.hwcgg.cn
http://XU15BioS.hwcgg.cn
http://gML2HkpU.hwcgg.cn
http://NkEJ2tgk.hwcgg.cn
http://www.dtcms.com/a/380770.html

相关文章:

  • [优选算法专题二——NO.16最小覆盖子串]
  • Nginx生产级优化配置全解析和配置原因解析
  • 14自由度汽车动力学模型
  • FS950R08A6P2B 双通道汽车级IGBT模块Infineon英飞凌 电子元器件核心解析
  • 交换机协议栈FRR中使用
  • C++ 二叉搜索树的详解与实现
  • 记录:离线部署
  • python逆向-逆向pyinstaller打包的exe程序反编译获取源代码
  • 最大连续 1 的个数
  • LVS负载均衡群集和LVS+Keepalived群集
  • 嵌入式开发:中断配置全解析
  • 【Vue3】07-利用setup编写vue(2)-setup的语法糖
  • 使用 信号量(Semaphore) 来控制异步任务并发数
  • 1688 商品 API 实战指南:B2B 场景下的合规对接与批量运营方案
  • Qt Bridge for Figma
  • 解决docker配置了镜像源但还会拉取官方镜像源的问题
  • 【JavaEE】网络原理初识
  • 操作系统应用开发(七)mac苹果模拟器——东方仙盟练气期
  • PBI Plus 技术解析:全渠道协同架构下的数据协作效率提升方案​
  • 【C#】三个特殊的 Caller Info Attributes
  • LangChain4j入门学习
  • Django ORM 模型
  • 【SpringBoot】——原理篇
  • 机器人防爆的详细讲解
  • 【Vue3】06-利用setup编写vue(1)
  • 单序列双指针
  • Linux中进程和线程常用的API详解
  • 【AI论文】多模态大型语言模型的视觉表征对齐
  • php学习(第四天)
  • Vue中使用keep-alive实现页面前进刷新、后退缓存的完整方案