mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
19 lines
297 B
TypeScript
19 lines
297 B
TypeScript
import { nextTick, onMounted, onActivated } from 'vue';
|
|
|
|
export function onMountedOrActivated(hook: () => any) {
|
|
let mounted: boolean;
|
|
|
|
onMounted(() => {
|
|
hook();
|
|
nextTick(() => {
|
|
mounted = true;
|
|
});
|
|
});
|
|
|
|
onActivated(() => {
|
|
if (mounted) {
|
|
hook();
|
|
}
|
|
});
|
|
}
|