refactor: 优化数据加载逻辑.

This commit is contained in:
lijiahangmax
2023-12-02 23:36:02 +08:00
parent 9f35fb855d
commit a22f30a8b4
19 changed files with 155 additions and 117 deletions

View File

@@ -1,3 +1,6 @@
// 添加事件监听器
import { Ref } from 'vue';
export function addEventListen(
target: Window | HTMLElement,
event: string,
@@ -12,6 +15,7 @@ export function addEventListen(
}
}
// 移除事件监听器
export function removeEventListen(
target: Window | HTMLElement,
event: string,
@@ -25,3 +29,13 @@ export function removeEventListen(
target.removeEventListener(event, handler, capture);
}
}
// 触发鼠标事件
export const triggerMouseEvent = (ref: Ref, e = 'click') => {
const event = new MouseEvent(e, {
view: window,
bubbles: true,
cancelable: true,
});
ref.value.dispatchEvent(event);
};