The page in vue is destroyed, and the timer is still going?

1: in mounted () {

this.timer = setInterval(() => {
    this.rechargeInfo();
}, 3000);

} create a timer.
2:
beforeDestroy () {

when the aspect route is redirected
this.timer = null;
clearInterval(this.timer);

},
destroyed () {

this.timer = null;
clearInterval(this.timer);

} to clear
.
in theory, the timer is cleared when the component is destroyed. ,
but: the timer is still running when you jump to another page.
question.


this.timer = null;
clearInterval(this.timer);

is it in reverse order. If you write clearInterval in this way, the parameter is null how can you destroy the timer correctly

clearInterval(this.timer);
this.timer = null;

try it like this


you want to call the destroy hook destroy clearing timer


this.timer = null; this has affected, just remove it

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47d7d-44c6c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47d7d-44c6c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?