8000 docs: mention `#components` import for dynamic component (#22231) · nuxt/nuxt@6c517e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c517e9

Browse files
authored
docs: mention #components import for dynamic component (#22231)
1 parent 1f1de38 commit 6c517e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/2.guide/2.directory-structure/1.components.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,20 @@ This registers the components using the same strategy as used in Nuxt 2. For exa
9898

9999
## Dynamic Components
100100

101-
If you want to use the Vue `<component :is="someComputedComponent">` syntax, then you will need to use the `resolveComponent` helper provided by Vue.
101+
If you want to use the Vue `<component :is="someComputedComponent">` syntax, you need to use the `resolveComponent` helper provided by Vue or import the component directly from `#components` and pass it into `is` prop.
102102

103103
For example:
104104

105105
```vue
106106
<script setup lang="ts">
107+
import { SomeComponent } from '#components'
108+
107109
const MyButton = resolveComponent('MyButton')
108110
</script>
109111
110112
<template>
111113
<component :is="clickable ? MyButton : 'div'" />
114+
<component :is="SomeComponent" />
112115
</template>
113116
```
114117

0 commit comments

Comments
 (0)
0