[英]can't display page when i run on local server
Every time I try to run my code on a local server, my laptop gets so slow and warm and the page won't display as shown below. 每次尝试在本地服务器上运行代码时,我的笔记本电脑都变得如此缓慢和发热,并且该页面不会显示如下。
The source code looks like I am in an infinite loop but can't figure out what's wrong. 源代码看起来像是处于无限循环中,但无法弄清楚出了什么问题。
deck.addEventListener('click', event => {
const clickTarget = event.target;
if (clickTarget.classList.contains('card') &&
!clickTarget.classList.contains('match') && toggledCards.length < 2 &&
!toggledCards.includes(clickTarget)) {
toggleCard(clickTarget);
addToggleCard(clickTarget);
if (toggledCards.length === 2) {
checkForMatch(clickTarget);
}
}
});
99% times when cpu goes crazy and that pop up shows. 当cpu疯狂并弹出时显示99%的时间。 It's because of a endless loop.
这是因为循环不断。
Probably one of the called functions, makes a click somewhere. 可能是其中一个被调用的函数,在某处单击。 To avoid it you have to debug the functions like @dustytrash advised.
为了避免这种情况,您必须调试@dustytrash建议的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.