JeecgBoot 3.6.1版本发布——ONLINE专题版本

pull/975/head
zhangdaiscott 2023-12-08 12:56:52 +08:00
parent 06a13a9acd
commit 2ee3d66d7e
1 changed files with 7 additions and 3 deletions

View File

@ -1,10 +1,14 @@
import { nextTick, onMounted, onActivated } from 'vue'; import { nextTick, onMounted, onActivated } from 'vue';
export function onMountedOrActivated(hook: Fn) { type HookArgs = {
type: 'mounted' | 'activated';
}
export function onMountedOrActivated(hook: Fn<HookArgs, any>) {
let mounted: boolean; let mounted: boolean;
onMounted(() => { onMounted(() => {
hook(); hook({type: 'mounted'});
nextTick(() => { nextTick(() => {
mounted = true; mounted = true;
}); });
@ -12,7 +16,7 @@ export function onMountedOrActivated(hook: Fn) {
onActivated(() => { onActivated(() => {
if (mounted) { if (mounted) {
hook(); hook({type: 'activated'});
} }
}); });
} }