8000 Update options-api.md (#476) · vuejs-translations/docs-zh-cn@a24fd5d · GitHub
[go: up one dir, main page]

Skip to content

Commit a24fd5d

Browse files
chunjin666wxsms
andauthored
Update options-api.md (#476)
* Update options-api.md 同步英文文档此处关于 prop 注意事项的更新 vuejs/docs#1853 * Apply suggestions from code review Co-authored-by: wxsm <wxsms@foxmail.com>
1 parent c0cbcb3 commit a24fd5d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/guide/typescript/options-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default defineComponent({
6767

6868
### 注意事项 {#caveats}
6969

70-
因为一个 TypeScript [设计限制](https://github.com/microsoft/TypeScript/issues/38845),你在使用函数作为 prop 的 `validator``default` 选项值时需要格外小心——确保使用箭头函数:
70+
如果你的 TypeScript 版本低于 `4.7`,在使用函数作为 prop 的 `validator``default` 选项值时需要格外小心——确保使用箭头函数:
7171

7272
```ts
7373
import { defineComponent } from 'vue'
@@ -82,7 +82,7 @@ export default defineComponent({
8282
props: {
8383
bookA: {
8484
type: Object as PropType<Book>,
85-
// 确保使用箭头函数
85+
// 如果你的 TypeScript 版本低于 4.7,确保使用箭头函数
8686
default: () => ({
8787
title: 'Arrow Function Expression'
8888
}),
@@ -92,7 +92,7 @@ export default defineComponent({
9292
})
9393
```
9494

95-
这会防止 Typescript`this` 根据函数内的环境作出不符合我们期望的类型推导。
95+
这会防止 TypeScript`this` 根据函数内的环境作出不符合我们期望的类型推导。这是之前版本的一个[设计限制](https://github.com/microsoft/TypeScript/issues/38845),不过现在已经在 [TypeScript 4.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#improved-function-inference-in-objects-and-methods) 中解决了
9696

9797
## 为组件的 emit 标注类型 {#typing-component-emits}
9898

0 commit comments

Comments
 (0)
0