Invalid vue cleanup timer

The

code is as follows. The timer is still running after jumping to the page

created(){
    this.interval()
},
beforeDestroy () {
    console.log("")
    clearInterval(this.interval)
},
methods: {
    interval(){
        setInterval(()=>{
            console.log("")
            this.loadList()
        },3000)
    },
}
Apr.25,2021

clears the reference to the timer, not the method

created(){
    this.interval()
},
beforeDestroy () {
    console.log('')
    clearInterval(this._inter)
},
methods: {
    interval(){
        this._inter = setInterval(()=>{
            console.log('')
            this.loadList()
        },3000)
    },
}
The parameter of the

clearInterval () method must be the ID value returned by setInterval () .
what you pass to it from this code snippet is a function that must not be cleared

.
Menu