"1721008965149.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240920/03c2f2de6abb752b53c657c1b8bb88d4.png) clearInterval也可以清除掉setTimeout吗? var a = setTimeout(() => {console.log(111)}, 10000) clearInterval(a)
为什么clearinterval不生效? react的项目,在函数组件中定义了定时器容器: var timer = { sto: [], //存延时器 siv: [], //存循环器 }; 想通过鼠标移入控制定时器启停 于是定义了 function handleMouseOver(){ if(timer.siv.length>0){ timer.siv.forEach(siv=>clearInterval(siv)) }else{ timer.siv.forEach(siv=>clearInterval(siv)); timer.siv.push(setInterval(()=>{console.log("xxx")},50)); } }