量测:关闭页面时清除定时器
This commit is contained in:
parent
e723ce4d93
commit
06bc07bfcd
@ -155,7 +155,7 @@ const getCompleteData = () => {
|
||||
return getRealValueList({ deviceId: props.deviceId, attributes: codeList }, data)
|
||||
})
|
||||
.then((realData: any) => {
|
||||
console.log(realData);
|
||||
console.log(realData)
|
||||
|
||||
const data = realData.list.map((item: any) => {
|
||||
const realValItem = realData.realVal[props.deviceId]?.[item.attributeCode?.toLowerCase()]
|
||||
@ -207,25 +207,30 @@ const openChart = (data: any) => {}
|
||||
watch(
|
||||
() => props.show,
|
||||
(newVal) => {
|
||||
newVal && getCompleteData()
|
||||
if (newVal) {
|
||||
getCompleteData()
|
||||
} else {
|
||||
autoUpdateTimer.value && clearInterval(autoUpdateTimer.value)
|
||||
autoUpdateTimer.value = null
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
)
|
||||
let autoUpdateTimer: any = null
|
||||
const autoUpdateTimer: any = ref(null)
|
||||
watch(
|
||||
() => props.autoUpdate,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
if (!autoUpdateTimer) {
|
||||
autoUpdateTimer = setInterval(() => {
|
||||
if (!autoUpdateTimer.value) {
|
||||
autoUpdateTimer.value = setInterval(() => {
|
||||
getCompleteData()
|
||||
}, 2000)
|
||||
}
|
||||
} else {
|
||||
clearInterval(autoUpdateTimer)
|
||||
autoUpdateTimer = null
|
||||
clearInterval(autoUpdateTimer.value)
|
||||
autoUpdateTimer.value = null
|
||||
}
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user