阅读背景:

js发布订阅简洁版

来源:互联网 
var event = { items: {}, on: function (type, fn) { if (!this.items[type]) { this.items[type] = [] } this.items[type].push(fn) }, emit: function (type) { for (var i in this.items) { if (i == type) { this.items[type].forEach(fn => fn()) } } }, off: function (type) { if (type) { delete this.items[type] } else { this.items = {} } } } var event = { items: {}, on: function (type, fn)



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: