chore(Sticky): avoid repeated observe

This commit is contained in:
chenjiahan 2020-11-11 22:45:34 +08:00
parent 0712d92063
commit 37a38c887f

View File

@ -1,11 +1,6 @@
import { inBrowser } from '../utils';
import {
Ref,
onMounted,
onActivated,
onDeactivated,
onBeforeUnmount,
} from 'vue';
import { Ref, onDeactivated, onBeforeUnmount } from 'vue';
import { onMountedOrActivated } from '@vant/use';
// @Experimental
export function useVisibilityChange(
@ -37,8 +32,7 @@ export function useVisibilityChange(
}
};
onMounted(observe);
onActivated(observe);
onDeactivated(unobserve);
onBeforeUnmount(unobserve);
onMountedOrActivated(observe);
}