我不明白为什么这个函数认为 a)
从最后丢失了。当我放置)
它时,它会创建一个自执行函数并生成不是我想要的 javascript。
作品
this.Events.off = (): any {
var events = arguments[0],
callback = arguments[1];
if (typeof events === 'string' && typeof callback === 'function') {
this._events.off.call(this._events, events, callback);
}
else if (typeof callback === 'function') {
this._events.off.call(this._events, callback);
}
};
错误
declare var $, Backbone;
export class WebControls {
_events;
Events;
constructor (options? ) {
this._events = $.extend({}, Backbone.Events);
this.Events = {};
this.Events.on = (events: string, cb: (event: any) => any) {
this._events.on.apply(this._events, arguments);
};
this.Events.trigger = (eventName: string, ...args: any[]): any {
this._events.trigger.apply(this._events, arguments);
};
this.Events.off = (events?: string, callback?: any) : any {
if (typeof events === 'string' && typeof callback === 'function') {
this._events.off.call(this._events, events, callback);
} else if (typeof callback === 'function') {
this._events.off.call(this._events, callback);
}
};
}
}
我在这里盲目地遗漏了一些明显的东西吗?