1, iframe.onload 加载成功之后调用的函数
2, iframe.contentWindow.print(); iframe 打印方法
<div
style="height:0px;width:0px; position: fixed; z-index: -100; opacity: 0;">
<iframe style="height:100%;width:100%;" :src="pdfprint" id="test" />
</div>
const pdfprint = ref()
const createQr = () => {
const paramss = {
content: JSON.stringify(qrdpdfcontent.value),
ywid: baseInfo.value.bsm,
pdfname: baseInfo.value.bsm,
}
net.file.generatePdf(paramss).then(ress => {
pdfimg.value = `/fileserver/${ress.result}`
pdfprint.value = pdfimg.value
if (pdfprint.value) {
const iframe = document.getElementById('test');
console.log(iframe, "iframe");
iframe.onload = function () {
console.log('加载完成');
iframe.contentWindow.print();
}
}
})
}