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

This commit is contained in:
cherishsince 2024-06-05 13:54:36 +08:00
parent c96f3cea61
commit 520244eea9

View File

@ -87,9 +87,10 @@ const downloadImage = async (imageUrl) => {
} }
} }
// /** 暴露组件方法 */
defineExpose({getImageList}) defineExpose({getImageList})
//
/** 组件挂在的时候 */
onMounted(async () => { onMounted(async () => {
// image // image
await getImageList() await getImageList()
@ -98,9 +99,12 @@ onMounted(async () => {
await getImageList() await getImageList()
}, 1000 * 20) }, 1000 * 20)
}) })
//
onUnmounted(async () => {
/** 组件取消挂在的时候 */
onUnmounted(async () => {
if (imageListInterval.value) {
clearInterval(imageListInterval.value)
}
}) })
</script> </script>