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

@@ -0,0 +1,26 @@
const emitter = 'emitter';
export default function useEmitter(emits: any) {
// 事件向上冒泡
const bubblesEmitter = (event: string, ...args: any[]) => {
if (args) {
emits(emitter, event, ...args);
} else {
emits(emitter, event);
}
};
// 处理冒泡事件
const dispatchEmitter = (event: string, ...args: any[]) => {
if (args) {
emits(event, ...args);
} else {
emits(event);
}
};
return {
bubblesEmitter,
dispatchEmitter
};
}