forked from wangjiadong/comp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
290 B
19 lines
290 B
1 year ago
|
import { nextTick, onMounted, onActivated } from 'vue';
|
||
|
|
||
|
export function onMountedOrActivated(hook: Fn) {
|
||
|
let mounted: boolean;
|
||
|
|
||
|
onMounted(() => {
|
||
|
hook();
|
||
|
nextTick(() => {
|
||
|
mounted = true;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
onActivated(() => {
|
||
|
if (mounted) {
|
||
|
hook();
|
||
|
}
|
||
|
});
|
||
|
}
|