04-Typescript 装饰器工厂

function logClassAgain(params: string) {
    return function (target: any) {
        target.prototype.path = `http://${params}`
    }
}

@logClassAgain('baidu.com')
class DecFact {
    constructor() {
    }
}

let testResult:any = new DecFact()

console.log(testResult.path)



你可能感兴趣的:(TypeScript入门,javascript,typescript,es6)