How to avoid hard coded this? in Decorators

前端 未结 2 1570
深忆病人
深忆病人 2020-12-29 14:45

I have read \"How to implement a typescript decorator?\" and multiple sources but there is something that i have nor been able to do with decorators.

class F         


        
2条回答
  •  庸人自扰
    2020-12-29 15:25

    I believe you can use

    var self = this;
    

    in order to preserve the 'this' at that specific point. Then, just use self at the later point where you would have wanted that particular this

提交回复
热议问题