//定义打印前事件
var beforePrint = function() {
console.log("beforePrint");
};
//定义打印后事件
var afterPrint = function() {
console.log("afterPrint");
}
//监听window状态
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
//为印添加事件
mediaQueryList.addListener(function(mql) {
if (mql.matches) {
beforePrint();
} else {
afterPrint();
}
});
}
//打印前事件
window.onbeforeprint = beforePrint;
//打印后事件
window.onafterprint = afterPrint;
$("#print").click(function(){
//执行打印
window.print();
});
以上是编程学习网小编为您介绍的“如何获取window.print()打印回调事件”的全面内容,想了解更多关于
vuejs 内容,请继续关注编程基础学习网。