vue3 請下載html-docx-js-typescript,否則會(huì)報(bào)錯(cuò)類型問題
//報(bào)告導(dǎo)出word
import * as htmlDocx from "html-docx-js-typescript";
//@ts-ignore
import { saveAs } from 'file-saver'
// 下載文件,
const downloadFile = (row)=> {
try {
const convertedFile = htmlDocx.asBlob(htmlstr);
// 生成鏈接并且下載
// const fileData = convertedFile
convertedFile.then((fileData)=>{
console.log(htmlstr,fileData)
saveAs((fileData as Blob), row.reportName+'.docx', { encoding: 'UTF-8' })
})
} catch (error) {
console.log(error)
}
}
row.report效果及數(shù)據(jù)文章來源:http://www.zghlxwxcb.cn/news/detail-681628.html
<p class="MsoNormal" style="line-height: 28.0pt; mso-line-height-rule: exactly; vertical-align: baseline;"> </p>
<p class="MsoNormal" style="text-align: center; line-height: 28.0pt; mso-line-height-rule: exactly; vertical-align: baseline;" align="center"><span style="font-size: 22.0pt; font-family: 方正小標(biāo)宋_GBK; mso-hansi-font-family: 方正小標(biāo)宋_GBK; letter-spacing: -.3pt;">數(shù)據(jù)質(zhì)量報(bào)告模板</span></p>
<p style="text-align: center; line-height: 28.0pt; mso-line-height-rule: exactly; tab-stops: 92.15pt; text-autospace: none;" align="center"><span lang="EN-US" style="font-size: 16.0pt; mso-bidi-font-size: 10.0pt; font-family: 方正楷體_GBK; mso-hansi-font-family: 方正楷體_GBK; mso-bidi-font-family: 方正楷體_GBK; mso-font-kerning: 0pt;"> </span></p>
<p class="MsoNormal" style="text-indent: 30.8pt; mso-char-indent-count: 2.0; line-height: 28.0pt; mso-line-height-rule: exactly; mso-outline-level: 1;"><span style="font-size: 16.0pt; mso-bidi-font-size: 10.0pt; font-family: 方正黑體_GBK; mso-hansi-font-family: 方正黑體_GBK; letter-spacing: -.3pt;">一、總體情況</span></p>
<p class="MsoNormal" style="text-indent: 32.0pt; mso-char-indent-count: 2.0; line-height: 28.0pt; mso-line-height-rule: exactly;"><span style="font-size: 16.0pt; font-family: 方正仿宋_GBK; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; mso-bidi-language: AR;">截至</span><span lang="EN-US" style="font-size: 16.0pt; font-family: 方正仿宋_GBK; mso-fareast-font-family: 宋體; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; color: blue; mso-bidi-language: AR;"><</span><span style="font-size: 16.0pt; font-family: 宋體; mso-ascii-font-family: 方正仿宋_GBK; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; color: blue; mso-bidi-language: AR;">日期函數(shù)</span><span lang="EN-US" style="font-size: 16.0pt; font-family: 方正仿宋_GBK; mso-fareast-font-family: 宋體; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; color: blue; mso-bidi-language: AR;">></span><span style="font-size: 16.0pt; font-family: 方正仿宋_GBK; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; mso-bidi-language: AR;">,發(fā)現(xiàn)問題數(shù)據(jù)</span><span lang="EN-US" style="font-size: 16.0pt; font-family: 方正仿宋_GBK; mso-fareast-font-family: 宋體; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; color: blue; mso-bidi-language: AR;"><</span><span style="font-size: 16.0pt; font-family: 宋體; mso-ascii-font-family: 方正仿宋_GBK; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; color: blue; mso-bidi-language: AR;">發(fā)現(xiàn)問題數(shù)據(jù)</span><span lang="EN-US" style="font-size: 16.0pt; font-family: 方正仿宋_GBK; mso-fareast-font-family: 宋體; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; color: blue; mso-bidi-language: AR;">></span><span style="font-size: 16.0pt; font-family: 方正仿宋_GBK; mso-hansi-font-family: 方正仿宋_GBK; mso-bidi-font-family: 方正仿宋_GBK; mso-bidi-language: AR;">條,</span></p>
調(diào)用文章來源地址http://www.zghlxwxcb.cn/news/detail-681628.html
到了這里,關(guān)于vue3+ts+tinynce富文本編輯器+htmlDocx+file-saver 配合實(shí)現(xiàn)word下載的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!