mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
docs: mention #components
import for dynamic component (#22231)
This commit is contained in:
parent
1f1de38d03
commit
6c517e919c
@ -98,17 +98,20 @@ This registers the components using the same strategy as used in Nuxt 2. For exa
|
|||||||
|
|
||||||
## Dynamic Components
|
## Dynamic Components
|
||||||
|
|
||||||
If you want to use the Vue `<component :is="someComputedComponent">` syntax, then you will need to use the `resolveComponent` helper provided by Vue.
|
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.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```vue
|
```vue
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { SomeComponent } from '#components'
|
||||||
|
|
||||||
const MyButton = resolveComponent('MyButton')
|
const MyButton = resolveComponent('MyButton')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<component :is="clickable ? MyButton : 'div'" />
|
<component :is="clickable ? MyButton : 'div'" />
|
||||||
|
<component :is="SomeComponent" />
|
||||||
</template>
|
</template>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user