首页 > 其他分享 >vue3 每隔2分钟发送一次请求,并更新界面

vue3 每隔2分钟发送一次请求,并更新界面

时间:2023-01-16 10:23:56浏览次数:41  
标签:dataInfo fetchData timer value vue3 界面 每隔 const

如下:

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
})

  

标签:dataInfo,fetchData,timer,value,vue3,界面,每隔,const
From: https://www.cnblogs.com/wangpengfei-CN/p/17054788.html

相关文章