!66 在goods-list.vue页面销毁时移除 resize 事件监听器

Merge pull request !66 from luoyangxin/master
This commit is contained in:
1024创新实验室 2025-04-27 07:29:12 +00:00 committed by Gitee
commit 57270a7130
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -498,9 +498,7 @@
//
const yHeight = ref(0);
onMounted(() => {
resetGetHeight();
});
function resetGetHeight() {
//
let doc = document.querySelector('.ant-form');
@ -517,10 +515,20 @@
yHeight.value = box.offsetHeight - dueHeight;
}, 100);
}
window.addEventListener(
'resize',
_.throttle(() => {
//
let throttledResizeHandler;
onMounted(() => {
resetGetHeight();
}, 1000)
);
throttledResizeHandler = _.throttle(() => {
resetGetHeight();
}, 1000);
window.addEventListener('resize', throttledResizeHandler);
});
// resize
onUnmounted(() => {
window.removeEventListener('resize', throttledResizeHandler);
});
</script>