Skip to content

Commit c56fc1a

Browse files
committed
Add an example of using defineComponent in a single-file component
vuejs/docs@8eaf11b#diff-c8904f42c96ea728eea302e9bc39484fbb58d2401b4017ad37ea848fc8f183e5
1 parent a050dac commit c56fc1a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/guide/typescript-support.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ const Component = defineComponent({
102102
})
103103
```
104104

105+
If you're using [single-file components](/guide/single-file-component.html) then this would typically be written as:
106+
107+
```vue
108+
<script lang="ts">
109+
import { defineComponent } from 'vue'
110+
111+
export default defineComponent({
112+
// type inference enabled
113+
})
114+
</script>
115+
```
116+
105117
## オプション API とともに使用する
106118

107119
TypeScript は明示的に型を定義することなく、ほとんどの型を推論できるようにあるべきです。例えば、数値である `count` プロパティを持つコンポーネントがある場合、文字列に特有のメソッドを呼び出すとエラーになります:

0 commit comments

Comments
 (0)