html页面下载为docx文档


1.安装要用到的两个插件:html-docx-js-typescript、file-saver。

2.导入两个方法:

import { asBlob } from 'html-docx-js-typescript';
import { saveAs } from 'file-saver';

3.使用:

const html = `
Document......
`;
asBlob(chuanshanjiaTemplate).then((data) => {
      saveAs(data, `文档名称.docx`); // save as docx file
});