jeecgboot vue3 ui
This commit is contained in:
18
src/hooks/core/onMountedOrActivated.ts
Normal file
18
src/hooks/core/onMountedOrActivated.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { nextTick, onMounted, onActivated } from 'vue';
|
||||
|
||||
export function onMountedOrActivated(hook: Fn) {
|
||||
let mounted: boolean;
|
||||
|
||||
onMounted(() => {
|
||||
hook();
|
||||
nextTick(() => {
|
||||
mounted = true;
|
||||
});
|
||||
});
|
||||
|
||||
onActivated(() => {
|
||||
if (mounted) {
|
||||
hook();
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user