mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-15 01:33:54 +00:00
unobserve if component unmounts
This commit is contained in:
parent
29b5a8fd97
commit
a082fce977
@ -205,7 +205,7 @@ export default defineComponent({
|
|||||||
document?.getElementById(`tabitem${e}`)?.scrollIntoView();
|
document?.getElementById(`tabitem${e}`)?.scrollIntoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
function observeItems() {
|
function observeItems(kill = false) {
|
||||||
const observer = new IntersectionObserver((entries) => {
|
const observer = new IntersectionObserver((entries) => {
|
||||||
entries.forEach(
|
entries.forEach(
|
||||||
(element) => {
|
(element) => {
|
||||||
@ -224,6 +224,11 @@ export default defineComponent({
|
|||||||
document.querySelectorAll(".tabitem").forEach((element) => {
|
document.querySelectorAll(".tabitem").forEach((element) => {
|
||||||
observer.observe(element);
|
observer.observe(element);
|
||||||
});
|
});
|
||||||
|
if (kill) {
|
||||||
|
document.querySelectorAll(".tabitem").forEach((element) => {
|
||||||
|
observer.unobserve(element);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -319,7 +324,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
observeItems.unobserve();
|
observeItems(true);
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
currentItem,
|
currentItem,
|
||||||
|
Loading…
Reference in New Issue
Block a user