How to use setInterval and clearInterval?

前端 未结 5 1038
盖世英雄少女心
盖世英雄少女心 2020-11-22 03:58
function doKeyDown(event) {
    switch (event.keyCode) {
    case 32:
        /* Space bar was pressed */
        if (x == 4) {
            setInterval(drawAll, 20);         


        
5条回答
  •  迷失自我
    2020-11-22 04:28

    I used angular with electron,

    In my case, setInterval returns a Nodejs Timer object. which when I called clearInterval(timerobject) it did not work.

    I had to get the id first and call to clearInterval

    clearInterval(timerobject._id)

    I have struggled many hours with this. hope this helps.

提交回复
热议问题