vue-print-nb
vue-print-nb copied to clipboard
最新版本把之前修复的IE浏览器只能调起一次打印问题又带回来了
最新版本把之前修复的IE浏览器只能调起一次打印问题又带回来了,1.6.0版本是修复了这个问题,但是最新的1.7.4又有问题,不升级到最新版本又会存在另一个问题,就是打印内容缺失,请问怎么解决,感谢!
有代码吗??看看是怎么样调用的
我通过修改源码暂时解决了,看过源码后,发现几个问题,请老师看下是否是问题:
1、print方法事件绑定在IE浏览器偶发出现绑定对象不存在,我做了如下修改,测试后暂无问题,看看老师那边有没有更好的解决方式:
print (iframe) { let _this = this let _iframe = iframe.f let iframeWin = _iframe.contentWindow const _loaded = function () { iframeWin.focus() iframeWin.print() _iframe.parentNode.removeChild(_iframe) _this.removeCanvasImg() } setTimeout(function () { _loaded() }, 500) }
2、getHeader方法中获取style的方式,cssRules可能会报没有权限获取,且遍历比较耗时,我修改成如下写法,老师看下是否有更好的方式:
getHead () { let extraHead = '' let links = '' let style = '' if (this.settings.extraHead) { this.settings.extraHead.replace(/([^,]+)/g, (m) => { extraHead += m }) } // 复制所有link标签 const linksArray = document.querySelectorAll('link') if (linksArray.length > 0) { document.querySelectorAll('link').forEach(function (item) { if (item.href.indexOf('.css') >= 0) { links +=
} }) } // 循环获取style标签的样式 const stylesArray = document.querySelectorAll('style') if (stylesArray.length > 0) { document.querySelectorAll('style').forEach(function (item) { style += item.innerHTML }) } if (this.settings.extraCss) { this.settings.extraCss.replace(/([^,\s]+)/g, (m) => { links +=
}) } return
}