添加清楚state事件

This commit is contained in:
赛伊德
2025-10-28 14:51:14 +08:00
parent 0040bd91b4
commit baff697b4f
5 changed files with 24 additions and 2 deletions

15
src/utils/myEvent.js Normal file
View File

@@ -0,0 +1,15 @@
class MyEvent {
static list = []
add(name, call) {
MyEvent.list.push({ name, call })
}
remove(name, call) {
MyEvent.list = MyEvent.list.filter(item => item.name != name && item.call != call)
}
emit(name, data) {
MyEvent.list.forEach(item => {
if (item.name == name) item.call(data)
})
}
}
export default new MyEvent()