zoukankan      html  css  js  c++  java
  • 装饰器

    • 函数装饰器
    MethodDecorator = <T>(target: Object, key: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | Void;
    
    • 属性装饰器
    PropertyDecorator = (target: Object, key: string) => void;
    
    • class装饰器
    ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction;
    

      

    function funcDecorator(target, key, desc) {
        console.log('funcDecorator_target', target);
        console.log('funcDecorator_key', key);
        console.log('funcDecorator_desc', desc);
        return desc;
    }
    
    function propDecorator(target, key) {
        console.log('propDecorator_target', target);
        console.log('propDecorator_key', key);
    }
    
    function classDecorator(target) {
        console.log('classDecorator_target', target);
        return target;
    }
    
    @classDecorator
    export class Test {
        @propDecorator
        public name: string = '';
    
        @funcDecorator
        public log(): void {}
    }
    

      

    以自己现在的努力程度,还没有资格和别人拼天赋
  • 相关阅读:
    Django Rest Framework 视图和路由
    DRF 权限 频率
    DRF 版本 认证
    Serializers 序列化组件
    学DRF之前
    RESTful
    windows下vmware配置nat网络
    python之路——网络编程
    图片上传
    数据库基本设计规范:
  • 原文地址:https://www.cnblogs.com/zhenjianyu/p/15169648.html
Copyright © 2011-2022 走看看