如何实现?
npm i docxtemplater jszip-utils file-saver jszip@2.6.1
import Docxtemplater from 'docxtemplater'
import JSZipUtils from 'jszip-utils'
import { saveAs } from 'file-saver'
import JSZip from 'jszip'
wordData: any = {
title: "5月监控月报",
data: [
{
name: "天气雷达",
remark: "remark1",
status: "70%"
},
{
name: "探空雷达",
remark: "remark2",
status: "72%"
}
]
}
放入word模板,在vue项目的public文件下面,且必须是.docx,不能是.doc
exportWord () {
let _this = this
// 读取并获得模板文件的二进制内容
JSZipUtils.getBinaryContent('report/word.docx', function (error:any, content:any) {
if (error) throw