javascript - Error reported when setTimeout replaces setInterval to implement countdown
ringa_lee
ringa_lee 2017-05-19 10:38:45
0
1
456

Recently, when using vue2 to build a project, I encountered the need for an active countdown. When using setTimeout to simulate the effect of setInterval, something went wrong (of course, using the latter can easily solve the problem)

let myTimer = setTimeout( () => {
    if (diffTimer > 0) {
        hours = Math.floor(diffTimer/3600);
        minutes = Math.floor((diffTimer/60)%60);
        seconds = Math.floor(diffTimer%60);
        this.hours = hours > 9 ? hours : '0' + hours;
        this.minutes = minutes > 9 ? minutes : '0' + minutes;
        this.seconds = seconds > 9 ? seconds : '0' + seconds;
    } else {
        clearTimeout(myTimer);
    }
    diffTimer--;
    setTimeout(arguments.callee,1000);
},1000)

The result is the following error:

It seems that the arguments object cannot be found in the strict mode of es6...

ringa_lee
ringa_lee

ringa_lee

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!