进入界面执行
onMounted(() => {
times();
});
const timer = ref();
//2秒一次
function times(){
timer.value = setInterval( () => {
select_time();
}, 2000)
}
//离开界面
onUnmounted(() => {
// 每次离开当前界面时,清除定时器
clearInterval(timer.value)
timer.value = null
})
//查询
function select_time(){
console.log(123456)
}
vue3进入界面,离开界面,定时
于 2023-08-31 14:27:15 首次发布