1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| import { onActivated, onDeactivated, ref } from 'vue';
|
| /**
| * 开启路由缓存页面,离开时,和进入时取消/开启订阅事件
| * @returns
| */
| export const usePageDisplay = (pageShow?: () => void, pageHide?: () => void) => {
| const haveExecutedMounted = ref(false);
| onActivated(() => {
| if (!haveExecutedMounted.value) {
| return;
| }
| pageShow?.();
| });
|
| onDeactivated(() => {
| pageHide?.();
| });
|
| return {
| haveExecutedMounted
| };
| };
|
|