vue3 每隔2分钟发送一次请求,并更新界面
如下:
const dataInfo = ref()
const timer = ref()
const fetchData = async () => {
await HnbdSystemUserListStatus().then((e) => {
if (e.code == 0) {
dataInfo.value = e.data
nextTick()
timer.value = setTimeout(() => {
fetchData()
}, 120000)
}
})
console.log('平台运行状态数据', dataInfo.value)
}
fetchData()
onBeforeUnmount(() => {
clearTimeout(timer.value)
timer.value = null
})
浙公网安备 33010602011771号