Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic slots section to key-attribute.md page. #668

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/guide/migration/key-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ badges:
- **NEW:** `key`s are no longer necessary on `v-if`/`v-else`/`v-else-if` branches, since Vue now automatically generates unique `key`s.
- **BREAKING:** If you manually provide `key`s, then each branch must use a unique `key`. You can no longer intentionally use the same `key` to force branch reuse.
- **BREAKING:** `<template v-for>` `key` should be placed on the `<template>` tag (rather than on its children).
- **BREAKING:** `key` should be placed on a `<slot>` tag with a dynamic name.

## Background

Expand Down Expand Up @@ -89,3 +90,23 @@ Similarly, when using `<template v-for>` with a child that uses `v-if`, the `key
<span v-else>...</span>
</template>
```

## Dynamic Slots

In Vue 2.x a `<slot>` tag with a dynamic name didn't require a `key` attribute.

```html
<!-- Vue 2.x -->
<template>
<slot :name="dynamicName">...</slot>
</template>
```

In Vue 3.x a `key` attribute is required for the slot contents to update dynamically.

```html
<!-- Vue 3.x -->
<template>
<slot :name="dynamicName" :key="dynamicName">...</slot>
</template>
```