微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

tc39 babel 装饰器,有没有办法使用方法装饰器访问类?

如何解决tc39 babel 装饰器,有没有办法使用方法装饰器访问类?

使用方法装饰器时如何访问类,在其上定义一些属性

class Test {
    @Meta
    hello() {}

    @Meta
    sayHi() {}
}

function Meta(descriptor) {
    // I want to access the Test class,assign custom config on it,// but the descriptor.finisher param only work for class decorator,// how to assign properties to the class
    // for example set Test.Meta = ['hello','sayHi'] when method hello,sayHi has this decorator
    // not on decorator legacy mode,// the descriptor is like {kind: 'method',placement: 'prototype',...}
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。