From a529d6c123ca934390b05500811a8c93de592ed8 Mon Sep 17 00:00:00 2001 From: ruanyf Date: Tue, 15 Aug 2023 20:13:38 +0800 Subject: [PATCH] docs(decorator): edit text --- docs/decorator.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/decorator.md b/docs/decorator.md index 70ea454..c8d0805 100644 --- a/docs/decorator.md +++ b/docs/decorator.md @@ -41,15 +41,15 @@ class A {} // "hi" ```typescript function simpleDecorator( - target:any, + value:any, context:any ) { - console.log('hi, this is ' + target); - return target; + console.log(`hi, this is ${context.kind} ${context.name}`); + return value; } @simpleDecorator -class A {} // "hi, this is class A {}" +class A {} // "hi, this is class A" ``` 上面的代码就可以顺利通过编译了,代码含义这里先不解释。大家只要理解,类`A`在执行前会先执行装饰器`simpleDecorator()`,并且会向装饰器自动传入参数就可以了。