合并代码
This commit is contained in:
16
src/tool/myEvents.js
Normal file
16
src/tool/myEvents.js
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
class MyEvent{
|
||||
static list = []
|
||||
add(name,call){
|
||||
MyEvent.list.push({name,call})
|
||||
}
|
||||
remove(name,call){
|
||||
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()
|
||||
Reference in New Issue
Block a user