ES6--Decorator

{
    let readonly=function(target,name,descriptor){
        descriptor.writable=false;
        return descriptor;
    }
    class Test{
        @readonly
        time(){
            return '2017-034-11'
        }
    }
    let test=new Test();
    console.log(test.time())
}

你可能感兴趣的:(ES6--Decorator)