vue3中,markdown转html,再导出成为word文件

javascript 复制代码
function downLoad(message: Chat) {
      const md = new MarkdownIt1();
      const htmlContent = md.render(message.text);
      const title  = extractTitles(message.text);
      const temphtml = `<div>
     
     <div style="line-height:2px;width: 638px;border-top: 2px solid #ff0000; margin: 0 auto;">
      <span style="font-family:Arial">&nbsp;</span>
     </div>
      <p style="margin-top:2.15pt; margin-bottom:0pt; text-align:center; line-height:75%; font-size:21.5pt">
      <span style="font-family:'微软雅黑'">
${title}
      </span></p><p style="margin-top:11.3pt; margin-bottom:0pt; line-height:93%; font-size:15.5pt">
      <span style="font-family:FangSong">${htmlContent}</span></p></div>`
      const docx = htmlDocx.asBlob(temphtml)
      const fileName = 'my_document.docx'

      // 下载导出的文档
      const link = document.createElement('a')
      link.href = window.URL.createObjectURL(docx)
      link.download = fileName
      link.click()
}

import MarkdownIt1 from 'markdown-it';

import htmlDocx from 'html-docx-fixed/dist/html-docx';

相关推荐
星栈2 小时前
我在浏览器里试了试 PhotoCraft|Rust + WASM 修图,是玩具还是生产力?
前端
雨中飘荡的记忆3 小时前
淘宝搜不到的东西,能不能去全世界找?一个程序员的创业尝试
前端·设计
kyriewen3 小时前
我让 4 位 AI 面试官打分,同一个我差了 40 分
前端·面试·程序员
htzyl2064 小时前
Vue3中watch的deep默认值:reactive与ref为什么相反
前端·vue.js
用户112936112195 小时前
没写样式为什么还找我要 wxss?uni-app 这个 ENOENT 坑多数人误判了
前端·微信小程序·uni-app
用户553665935265 小时前
从零做一个全国山峰与线路库:山野抽签的初衷、架构与踩坑
前端
夕水5 小时前
用 SolidJS 复刻 DeepSeek Chat —— 顺便把 ew-solid-ui 拷打了一遍
前端·javascript
qq_274475155 小时前
第 17 篇:ES6 语法速览:解构赋值、展开运算符、模板字符串、对象简写
前端·ecmascript·es6
凯程序猿1号7 小时前
Web墨卡托EPSG3857瓦片行列号XYZ与经纬度双向换算及地面分辨率推导
前端·电脑
qq_274475157 小时前
第 21 篇:Proxy 代理与 Reflect:数据劫持基础,Vue 响应式底层原理前置
前端·javascript·vue.js