admin管理员组文章数量:1391934
Maybe it render, that took xxMS. What happen? Anytime I close the print page, I receive this message in the chrome console. Does anyone fix this problem?
<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();
},
},
Maybe it render, that took xxMS. What happen? Anytime I close the print page, I receive this message in the chrome console. Does anyone fix this problem?
<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();
},
},
Share
Improve this question
edited Mar 1, 2020 at 4:48
Tom
asked Mar 1, 2020 at 4:30
TomTom
211 silver badge3 bronze badges
2
- Can you also please show us the code for the button and for the event listener? – Sydney Y Commented Mar 1, 2020 at 4:32
- Sorry, I have edit my question, please review on it. Thanks – Tom Commented Mar 1, 2020 at 4:50
2 Answers
Reset to default 4The reason why you are getting this violation warning is likely because the event handler doesn't return until the print page is closed. So, when you click the button the print page opens, then nothing happens until the print page is closed, then the function returns.
I used onmouseover and Chrome doesn't show the violation, but Performance say Warning.
printScreen() {
let value = this.$refs.printparts;
let printPage = window.open();
printPage.focus();
printPage.document.body.insertAdjacentHTML('afterbegin', value.outerHTML);
printPage.onmouseover = function() {
printPage.print();
printPage.close();
};
return false;
},
本文标签: javascriptquotViolation 39click39 handler took 43665msquot in vuejsStack Overflow
版权声明:本文标题:javascript - "[Violation] 'click' handler took 43665ms" in vue.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744703232a2620684.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论