每五秒获取调取告警接口

  // 告警数量
  const getAlarm = () => {
    getAlarmCount().then(
      (res: any) => {
        if (res.code == 200) {
          setCount(res.data)
          clearTimeout(time)
          time = setTimeout(() => {
            getAlarm()
          }, 5000);
        }
      }
    )

  }
  useEffect(() => {
    getAlarm()
    return () => {
      clearTimeout(time)
    }
  }, [])
posted @ 2022-08-14 17:53  人心不古  阅读(25)  评论(0编辑  收藏  举报