data: () => ({
interval: 0,
counter: 0
}),
mounted () {
this.start()
},
methods: {
start () {
this.counter = 0
clearInterval(this.interval)
this.interval = setInterval( () => {
this.counter++
console.log(this.counter)
}, 1000)
},
stop () {
this.counter = 0
clearInterval(this.interval)
}
}