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

相关推荐
云枫晖5 分钟前
Webpack系列-Output出口
前端·webpack
用户2680013791910 分钟前
有哪些高效的Python库可以用于解析淘宝评论的JSON数据?
前端·api
brzhang13 分钟前
A Definition of AGI:用人的智力模型去量 AI,这事靠谱吗?
前端·后端·架构
一 乐13 分钟前
宠物管理|宠物店管理|基于SSM+vue的宠物店管理系统(源码+数据库+文档)
java·前端·数据库·vue.js·论文·毕设·宠物
咖啡の猫24 分钟前
Vue插件
前端·javascript·vue.js
韩劳模25 分钟前
Canvas、SVG实现不规则区域高亮的方案说明
前端
张可爱42 分钟前
20251026-从网页 Console 到 Python 爬虫:一次 B 站字幕自动抓取的实践与复盘
前端·python
咖啡の猫1 小时前
Vue中的自定义事件
前端·javascript·vue.js
yangwan1 小时前
Ubunut 22.04 安装 Docker 24.0.x
前端·后端