Open toRefs opened 3 years ago
function _setInterval (handle, delay) { let timer = { id: null } handle() function run () { timer.id = setTimeout(() => { run() handle() }, delay) }
run() return timer }
function _clearSetInterval ({ id }) { clearTimeout(id) }
let t = _setInterval(() => { console.log('hah') }, 1000)
setTimeout(() => { _clearSetInterval(t) }, 4000)
let t2 = _setInterval(() => { console.log('22222') }, 1000)
setTimeout(() => { _clearSetInterval(t2) }, 6000)
function _setInterval (handle, delay) { let timer = { id: null } handle() function run () { timer.id = setTimeout(() => { run() handle() }, delay) }
run() return timer }
function _clearSetInterval ({ id }) { clearTimeout(id) }
let t = _setInterval(() => { console.log('hah') }, 1000)
setTimeout(() => { _clearSetInterval(t) }, 4000)
let t2 = _setInterval(() => { console.log('22222') }, 1000)
setTimeout(() => { _clearSetInterval(t2) }, 6000)