第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Typescript裝飾器問題

Typescript裝飾器問題

瀟瀟雨雨 2019-03-21 18:15:44
在typescript中用裝飾器,對某個class上增加一些方法。//Decoratorexport default function eventDecorator(target: EventEmitterType) {    target.prototype.on = __event.on.bind(__event)    target.prototype.off = __event.off.bind(__event)    target.prototype.remove = __event.remove.bind(__event)    target.prototype.Events = __event.Events    target.prototype.emit = function(        eventName: string,        ...params: Array<string>    ) {        __event.emit.call(__event, eventName, this, ...params)    }}//class@eventDecoratorclass Test {    constructor() {        let _this = this as any        console.log(111111111)        _this.on('aa', this.callback)        _this.emit('aa', this)    }    callback() {        console.log(this)    }}new Test()這個時候直接調(diào)用this.on IDE無法識別裝飾器方法,改怎么寫,不用extends
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 411 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號