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

相关推荐
夜郎king7 分钟前
HTML5 SVG 实现日出日落动画与实时天气可视化
前端·html5·svg 日出日落
夏幻灵1 小时前
HTML5里最常用的十大标签
前端·html·html5
Mr Xu_1 小时前
Vue 3 中 watch 的使用详解:监听响应式数据变化的利器
前端·javascript·vue.js
未来龙皇小蓝1 小时前
RBAC前端架构-01:项目初始化
前端·架构
程序员agions2 小时前
2026年,微前端终于“死“了
前端·状态模式
万岳科技系统开发2 小时前
食堂采购系统源码库存扣减算法与并发控制实现详解
java·前端·数据库·算法
程序员猫哥_2 小时前
HTML 生成网页工具推荐:从手写代码到 AI 自动生成网页的进化路径
前端·人工智能·html
龙飞052 小时前
Systemd -systemctl - journalctl 速查表:服务管理 + 日志排障
linux·运维·前端·chrome·systemctl·journalctl
我爱加班、、2 小时前
Websocket能携带token过去后端吗
前端·后端·websocket
AAA阿giao2 小时前
从零拆解一个 React + TypeScript 的 TodoList:模块化、数据流与工程实践
前端·react.js·ui·typescript·前端框架