Browse Source

listeners支持object格式

es6
guy 3 years ago
parent
commit
c9a68fa87c
  1. 6
      src/core/3.ob.js

6
src/core/3.ob.js

@ -62,7 +62,11 @@
_initListeners: function () { _initListeners: function () {
var self = this; var self = this;
if (this.options.listeners != null) { if (this.options.listeners != null) {
_.each(this.options.listeners, function (lis) { _.each(this.options.listeners, function (lis, eventName) {
if (_.isFunction(lis)) {
self.on(eventName, _.bind(lis, self));
return;
}
(lis.target ? lis.target : self)[lis.once ? "once" : "on"] (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
(lis.eventName, _.bind(lis.action, self)); (lis.eventName, _.bind(lis.action, self));
}); });

Loading…
Cancel
Save