File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ export default defineComponent({
67
67
68
68
### 注意事项 {#caveats}
69
69
70
- 因为一个 TypeScript 的 [ 设计限制 ] ( https://github.com/microsoft/TypeScript/issues/38845 ) ,你在使用函数作为 prop 的 ` validator ` 和 ` default ` 选项值时需要格外小心——确保使用箭头函数:
70
+ 如果你的 TypeScript 版本低于 ` 4.7 ` ,在使用函数作为 prop 的 ` validator ` 和 ` default ` 选项值时需要格外小心——确保使用箭头函数:
71
71
72
72
``` ts
73
73
import { defineComponent } from ' vue'
@@ -82,7 +82,7 @@ export default defineComponent({
82
82
props: {
83
83
bookA: {
84
84
type: Object as PropType <Book >,
85
- // 确保使用箭头函数
85
+ // 如果 TypeScript 版本低于 4.7, 确保使用箭头函数
86
86
default : () => ({
87
87
title: ' Arrow Function Expression'
88
88
}),
@@ -92,7 +92,7 @@ export default defineComponent({
92
92
})
93
93
```
94
94
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 ) 版本被解决了 。
96
96
97
97
## 为组件的 emit 标注类型 {#typing-component-emits}
98
98
You can’t perform that action at this time.
0 commit comments