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

相关推荐
行走的陀螺仪1 小时前
uni-app + Vue3编辑页/新增页面给列表页传参
前端·vue.js·uni-app
We་ct2 小时前
LeetCode 205. 同构字符串:解题思路+代码优化全解析
前端·算法·leetcode·typescript
2301_812731412 小时前
CSS3笔记
前端·笔记·css3
ziblog2 小时前
CSS3白云飘动动画特效
前端·css·css3
越努力越幸运5082 小时前
CSS3学习之网格布局grid
前端·学习·css3
半斤鸡胗2 小时前
css3基础
前端·css
ziblog3 小时前
CSS3创意精美页面过渡动画效果
前端·css·css3
akangznl3 小时前
第四章 初识css3
前端·css·css3·html5
会豪3 小时前
深入理解 CSS3 滤镜(filter):从基础到实战进阶
前端·css·css3
头顶一只喵喵3 小时前
CSS3进阶知识:CSS3盒子模型,box-sizing:content-box和box-sizing:border-box的讲解
前端·css·css3