We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
@vue-generic
1 parent 1ce35a1 commit 25efd39Copy full SHA for 25efd39
src/api/sfc-script-setup.md
@@ -522,6 +522,18 @@ defineProps<{
522
</script>
523
```
524
525
+型を推論できない場合は、`@vue-generic` ディレクティブを使用して明示的な型を渡すことができます:
526
+
527
+```vue
528
+<template>
529
+ <!-- @vue-generic {import('@/api').Actor} -->
530
+ <ApiSelect v-model="selectedPeopleIds" endpoint="/api/actors" id-prop="actorId" />
531
532
+ <!-- @vue-generic {import('@/api').Genre} -->
533
+ <ApiSelect v-model="selectedGenreIds" endpoint="/api/genres" id-prop="genreId" />
534
+</template>
535
+```
536
537
`ref` でジェネリックコンポーネントへの参照を使用する場合、`InstanceType` は動作しないので、[`vue-component-type-helpers`](https://www.npmjs.com/package/vue-component-type-helpers) ライブラリーを使用する必要があります。
538
539
```vue
0 commit comments