mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-01-18 10:34:35 +00:00
23 lines
395 B
Vue
23 lines
395 B
Vue
import { nextTick, onMounted, onActivated } from 'vue';
|
|
|
|
type HookArgs = {
|
|
type: 'mounted' | 'activated';
|
|
}
|
|
|
|
export function onMountedOrActivated(hook: Fn<HookArgs, any>) {
|
|
let mounted: boolean;
|
|
|
|
onMounted(() => {
|
|
hook({type: 'mounted'});
|
|
nextTick(() => {
|
|
mounted = true;
|
|
});
|
|
});
|
|
|
|
onActivated(() => {
|
|
if (mounted) {
|
|
hook({type: 'activated'});
|
|
}
|
|
});
|
|
}
|