Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 523a963

Browse files
committedJul 27, 2023
docs: finish chapter decorator
1 parent 06c70f3 commit 523a963

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed
 

‎docs/decorator.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function decorator(
144144
- 'field'
145145
- 'accessor'
146146

147-
这表示一共有六种类型的装饰器。本章只介绍前五种装饰器,最后一种`accessor`暂时略过,它是一个全新的语法提案。
147+
这表示一共有六种类型的装饰器。
148148

149149
(2)`name`:字符串或者 Symbol 值,所装饰对象的名字,比如类名、属性名等。
150150

@@ -633,9 +633,7 @@ type ClassSetterDecorator = (
633633
) => Function | void;
634634
```
635635

636-
注意,getter
637-
装饰器的上下文对象`context``access`属性,只包含`get()`方法;setter
638-
装饰器的`access`属性,只包含`set()`方法。
636+
注意,getter 装饰器的上下文对象`context``access`属性,只包含`get()`方法;setter 装饰器的`access`属性,只包含`set()`方法。
639637

640638
这两个装饰器要么不返回值,要么返回一个函数,取代原来的取值器或存值器。
641639

@@ -738,8 +736,7 @@ type ClassAutoAccessorDecorator = (
738736
} | void;
739737
```
740738

741-
accessor
742-
装饰器的`value`参数,是一个包含`get()`方法和`set()`方法的对象。该装饰器可以不返回值,或者返回一个新的对象,用来取代原来的`get()`方法和`set()`方法。此外,装饰器返回的对象还可以包括一个`init()`方法,用来改变私有属性的初始值。
739+
accessor 装饰器的`value`参数,是一个包含`get()`方法和`set()`方法的对象。该装饰器可以不返回值,或者返回一个新的对象,用来取代原来的`get()`方法和`set()`方法。此外,装饰器返回的对象还可以包括一个`init()`方法,用来改变私有属性的初始值。
743740

744741
下面是一个例子。
745742

0 commit comments

Comments
 (0)
Please sign in to comment.