1. FileSaver.js + html-docx.js
<!-- 导出 word 文档 -->
function exportDocx() {
<!-- 克隆报告HTML -->
var contentDocument = document.getElementById("exam_Concent");
this.convertImagesToBase64(contentDocument);
var content = `<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
${
contentDocument.innerHTML}
</body>
</html>`;
var converted = htmlDocx.asBlob(content);
saveAs(converted, `文件.docx`)
纯前端将Html导出word
最新推荐文章于 2024-07-13 11:25:08 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)