Skip to content

Commit 102d3ef

Browse files
xmasuhainaokie
authored andcommitted
Update built-in-components.md (#1272)
provide keys to <component :is="vnode">
1 parent 3b0bdf9 commit 102d3ef

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/api/built-in-components.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ import { KeepAlive, Teleport, Transition, TransitionGroup } from 'vue'
6262

6363
Registration is not required if you pass the component itself to `is` rather than its name.
6464

65+
- **key:**
66+
67+
When using <component :is="vnode"> and passing vnode of the same type, you need to provide keys:
68+
69+
```html
70+
<component :is="current" :key="selected" />
71+
```
72+
73+
Otherwise, you are passing two compiled vnodes of the same type to the renderer. Because they are compiled as completely static, they will not be updated at all.
74+
6575
- **See also:** [Dynamic Components](../guide/component-dynamic-async.html)
6676

6777
## transition

0 commit comments

Comments
 (0)