-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: subclassing.md #49
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/mobx-docs-cn/zh-mobx-js-org/8u29bEMsuuPQDEvChsSgt1uj5tRg |
@iChenLei 已完成对subclassing.md的翻译,麻烦校对啦,谢谢 |
@ai-xiaihai ❤️ 感谢您的辛苦翻译。 cc @WanderWang @wangjq4214
|
docs/subclassing.md
Outdated
|
||
Subclassing is supported with [limitations](#limitations). Most notably you can only **override actions/flows/computeds on prototype** - you cannot override _[field declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#field_declarations)_. Use `override` annotation for methods/getters overriden in subclass - see example below. Try to keep things simple and prefer composition over inheritance. | ||
对使用子类的支持是有[限制](#limitations)的. 最值得注意的一点是你只能 **在原型里重新定义actions/flows/computeds** - 你不能重新定义 _[字段声明](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#field_declarations)_. 在子类中请使用 `override` 注释被重新定义的methods/getters - 见下例。 请凡事从简,并优先考虑组合(而非继承)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
重新定义原型中的 actions/flows/computeds
是否好一点
docs/subclassing.md
Outdated
1. [All other limitations apply as well](observable-state.html#limitations) | ||
1. 只有定义在**原型**上的 `action`, `computed`, `flow`, `action.bound` 可以在子类中被 **重新定义**。 | ||
1. 不能在子类中重新注释字段(`override` 除外)。 | ||
1. `makeAutoObservable` 不支持子类的使用. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不支持在子类中使用。
标点
docs/subclassing.md
Outdated
1. 只有定义在**原型**上的 `action`, `computed`, `flow`, `action.bound` 可以在子类中被 **重新定义**。 | ||
1. 不能在子类中重新注释字段(`override` 除外)。 | ||
1. `makeAutoObservable` 不支持子类的使用. | ||
1. 不支持扩展内置(`ObservableMap`, `ObservableArray`, 等)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不支持扩展内置数据结构(ObservableMap
, ObservableArray
, 等)。
使用中文括号?
docs/subclassing.md
Outdated
1. 不能在子类中重新注释字段(`override` 除外)。 | ||
1. `makeAutoObservable` 不支持子类的使用. | ||
1. 不支持扩展内置(`ObservableMap`, `ObservableArray`, 等)。 | ||
1. 你不能在子类中给`makeObservable` 提供不同选项。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你不能在子类中给 makeObservable
提供不同选项。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看起来和原来的一样 🤔 是typo吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我也没看出来区别 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加了个空格🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请问, 对于
- 中文中的 英文,
- 中文中的 小段代码
前后要不要加空格, 有没有什么统一的标准?
docs/subclassing.md
Outdated
|
||
### `TypeError: Cannot redefine property` | ||
|
||
If you see this, you're probably trying to **override arrow function** in subclass `x = () => {}`. That's not possible because **all annotated** fields of classes are **non-configurable** ([see limitations](observable-state.md#limitations)). You have two options: | ||
如果你遇见这一错误, 你可能正在子类中**重新定义箭头函数** `x = () => {}`. 其不可行的原因是**一切被注释的** 类字段都是**不可配置的** ([详见限制](observable-state.md#limitations)). 你有以下这两个选择: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
遇见=>遇到 是不是更书面一点
docs/subclassing.md
Outdated
|
||
### `TypeError: Cannot redefine property` | ||
|
||
If you see this, you're probably trying to **override arrow function** in subclass `x = () => {}`. That's not possible because **all annotated** fields of classes are **non-configurable** ([see limitations](observable-state.md#limitations)). You have two options: | ||
如果你遇见这一错误, 你可能正在子类中**重新定义箭头函数** `x = () => {}`. 其不可行的原因是**一切被注释的** 类字段都是**不可配置的** ([详见限制](observable-state.md#limitations)). 你有以下这两个选择: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加粗文字两侧是否有空格是否需要统一一下呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参照其他几个在校对中的PR,我会把空格都去掉 🚀
我已经依照评论做了更改, 内容在第二个commit中 🎉 |
No description provided.