每五秒获取调取告警接口
作者:互联网
// 告警数量
const getAlarm = () => {
getAlarmCount().then(
(res: any) => {
if (res.code == 200) {
setCount(res.data)
clearTimeout(time)
time = setTimeout(() => {
getAlarm()
}, 5000);
}
}
)
} useEffect(() => { getAlarm() return () => { clearTimeout(time) } }, [])
} useEffect(() => { getAlarm() return () => { clearTimeout(time) } }, [])
标签:res,五秒,getAlarm,time,告警,clearTimeout,调取 来源: https://www.cnblogs.com/yzy521/p/16585921.html