javascript - vue.js 中的“[Violation] 'click' 处理程序耗时 43665 毫秒”
问题描述
也许它渲染,这需要 xxMS。发生什么事?每当我关闭打印页面时,我都会在 chrome 控制台中收到此消息。有人解决这个问题吗?
<button @click="printScreen()" type="button">print</button>
<div ref="printparts">test</div>
methods: {
printScreen() {
let value = this.$refs.printparts;
let printPage = window.open();
printPage.focus();
printPage.document.body.insertAdjacentHTML('afterbegin', value.outerHTML);
printPage.print();
printPage.close();
},
},
解决方案
您收到此违规警告的原因可能是因为事件处理程序在打印页面关闭之前不会返回。因此,当您单击按钮时,打印页面打开,然后在关闭打印页面之前什么都不会发生,然后函数返回。
推荐阅读
- c++ - 12:00:01 AM 是有效时间吗?
- react-native - react-native:在 ubuntu 18.04 中找不到命令
- javascript - 我必须遍历多级 JSON 并删除某些键
- javascript - getText 和 getAttribute 为量角器中的输入字段获取空值
- pandas - Pandas-Groupby Plot 不适用于对象
- php - 尝试在 Amazon EC2 上升级 sqlite
- javascript - 如何在Javascript中获取类值
- eclipse - 从 Eclipse IDE 中的自定义插件加载类
- html - oauth2 回调按字面意思显示引用的样式表 css 文件
- logging - 这个日志怎么读?