Skip to content

Docs/162 fragments #163

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

Merged
merged 6 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const sidebar = {
'migration/functional-components',
'migration/async-components',
'migration/custom-directives',
'migration/fragments',
'migration/render-function-api',
'migration/slots-unification',
'migration/keycode-modifiers'
Expand Down
2 changes: 1 addition & 1 deletion src/guide/component-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ app.component('custom-layout', {
template: `
<header>...</header>
<main v-bind="$attrs">...</main>
<footer...></footer>
<footer>...</footer>
`
})
```
Expand Down
35 changes: 35 additions & 0 deletions src/guide/migration/fragments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Fragments

## Overview

In Vue 3, components now have official support for multi-root node components, i.e., fragments!

## Previous Syntax

In 2.x, multi-root components were not supported and would emit a warning when a user accidentally created one. As a result, many components are wrapped in a single `<div>` in order to fix this error.

```html
<!-- Layout.vue -->
<template>
<div>
<header>...</header>
<main>...</main>
<footer>...</footer>
</div>
</template>
```

## Current Syntax

In 3.x, components now can have multiple root nodes! However, this does require developers to explicitly define where attributes should be distributed.

```html
<!-- Layout.vue -->
<template>
<header>...</header>
<main v-bind="$attrs">...</main>
<footer>...</footer>
</template>
```

For more information on how attribute inheritance works, see [Non-Prop Attributes](/guide/component-props.html#disabling-attribute-inheritance).
36 changes: 18 additions & 18 deletions src/guide/migration/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ We're glad you asked! The answer is no. We've gone to great lengths to ensure mo

Possibly the biggest change is our new Composition API, which is entirely additive- the previous Options API will continue to be supported, as the Composition API is an advanced feature.

## Overview

### New Features

Some of the new features to keep an eye on in Vue 3 include:

- [Composition API](/guide/composition-api-introduction.html)
- [Teleport](/guide/teleport)
- [Fragments](/guide/migration/fragments)
- [Emits Component Option](/guide/component-custom-events.html)
- `createRenderer` API from `@vue/runtime-core` to create custom renderers

### Breaking

The following consists a list of breaking changes from v2:

- **keyCode support as `v-on` modifiers.** For more information, [see in-depth explanation](/guides/migration/keycodes.html)

## FAQ

> Where should I start in a migration?
Expand Down Expand Up @@ -37,21 +55,3 @@ It depends on a few factors:
> If I upgrade to Vue 3, will I also have to upgrade Vuex and Vue Router?

[//]: # 'TODO: still need to see where this lands'

## Overview

### New Features

Some of the new features to keep an eye on in Vue 3 include:

- [Composition API](/guide/composition-api-introduction.html)
- [Teleport](/guide/teleport)
- Fragments
- [Emits Component Option](/guide/component-custom-events.html)
- `createRenderer` API from `@vue/runtime-core` to create custom renderers

### Breaking

The following consists a list of breaking changes from v2:

- **keyCode support as `v-on` modifiers.** For more information, [see in-depth explanation](/guides/migration/keycodes.html)