【增加】Image 列表组件取消挂在 销毁定时刷

This commit is contained in:
cherishsince committed 2024-06-05 13:54:36 +08:00
1 parent c96f3cea61
commit 520244eea9
1 file changed
+8 -4
+8 -4
View File
@@ -87,9 +87,10 @@ const downloadImage = async (imageUrl) => {
}
}
//
/** 暴露组件方法 */
defineExpose({getImageList})
//
/** 组件挂在的时候 */
onMounted(async () => {
// 获取 image 列表
await getImageList()
@@ -98,9 +99,12 @@ onMounted(async () => {
await getImageList()
}, 1000 * 20)
})
//
onUnmounted(async () => {
/** 组件取消挂在的时候 */
onUnmounted(async () => {
if (imageListInterval.value) {
clearInterval(imageListInterval.value)
}
})
</script>