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';

相关推荐
极客密码22 分钟前
感谢雷总!Mimo大模型价值¥659/月的 MAX 套餐,让我免费领到了!
前端·ai编程·claude
深念Y1 小时前
我明白为什么B站没法在浏览器开直播了——Windows Chrome推流踩坑全记录
前端·chrome·webrtc·浏览器·srs·直播·flv
zhangxingchao1 小时前
AI应用开发七:可以替代 RAG 的技术
前端·人工智能·后端
Sun@happy2 小时前
现代 Web 前端渗透——基础篇(1)
前端·web安全
希冀1232 小时前
【CSS学习第十一篇】
前端·css·学习
隔窗听雨眠2 小时前
doctype、charset、meta如何控制整个渲染流水线
java·服务器·前端
kyriewen2 小时前
写组件文档写到吐?我用AI自动生成Storybook,同事以后直接抄
前端·javascript·面试
excel3 小时前
🧠 Prisma 表名大写 vs SQL 导出小写问题深度解析(附踩坑与解决方案)
前端·后端
周淳APP3 小时前
【前端工程化原理通识:从源头到运行时的理论阐述】
前端·编译·打包·前端工程化
五点六六六3 小时前
你敢信这是非Native页面写出来的渐变效果吗🌝(底层原理解析
前端·javascript·面试