Skip to content

Commit 2859a45

Browse files
authored
docs: include example of @vue-generic directive (#3219)
1 parent e35e97c commit 2859a45

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/api/sfc-script-setup.md

+12
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ defineProps<{
522522
</script>
523523
```
524524

525+
You can use `@vue-generic` the directive to pass in explicit types, for when the type cannot be inferred:
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+
525537
In order to use a reference to a generic component in a `ref` you need to use the [`vue-component-type-helpers`](https://www.npmjs.com/package/vue-component-type-helpers) library as `InstanceType` won't work.
526538

527539
```vue

0 commit comments

Comments
 (0)