Skip to content

Commit 70c1e83

Browse files
authored
docs: update menu and migration guides
1 parent 8d8d190 commit 70c1e83

File tree

5 files changed

+84
-19
lines changed

5 files changed

+84
-19
lines changed

src/.vuepress/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const sidebar = {
107107
]
108108
},
109109
{
110-
title: 'Migration from Vue 2',
110+
title: 'Migration Guide',
111111
collapsable: true,
112112
children: [
113113
'migration/introduction',
@@ -240,7 +240,7 @@ module.exports = {
240240
link: '/guide/introduction'
241241
},
242242
{
243-
text: 'v3 Migration Guide',
243+
text: 'Migration Guide',
244244
link: '/guide/migration/introduction'
245245
},
246246
{

src/guide/migration/introduction.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Some of the new features to keep an eye on in Vue 3 include:
4747

4848
## Breaking Changes
4949

50-
::: tip NOTE
50+
::: info INFO
5151
We are still working on a dedicated Migration Build of Vue 3 with Vue 2 compatible behavior and runtime warnings of incompatible usage. If you are planning to migrate a non-trivial Vue 2 app, we strongly recommend waiting for the Migration Build for a smoother experience.
5252
:::
5353

@@ -84,15 +84,15 @@ The following consists a list of breaking changes from 2.x:
8484

8585
### Other Minor Changes
8686

87-
- The ~~`destroyed`~~ lifecycle option has been renamed to `unmounted`
88-
- The ~~`beforeDestroy`~~ lifecycle option has been renamed to `beforeUnmount`
87+
- The `destroyed` lifecycle option has been renamed to `unmounted`
88+
- The `beforeDestroy` lifecycle option has been renamed to `beforeUnmount`
8989
- [Props `default` factory function no longer has access to `this` context](/guide/migration/props-default-this.html)
9090
- [Custom directive API changed to align with component lifecycle](/guide/migration/custom-directives.html)
9191
- [The `data` option should always be declared as a function](/guide/migration/data-option.html)
9292
- [The `data` option from mixins is now merged shallowly](/guide/migration/data-option.html#mixin-merge-behavior-change)
9393
- [Attributes coercion strategy changed](/guide/migration/attribute-coercion.html)
9494
- [Some transition classes got a rename](/guide/migration/transition.html)
95-
- When using [the `watch` option](/api/options-data.html#watch) to watch an array, the callback will only trigger when the array is replaced, and no longer trigger on array mutation. To trigger on mutation, the `deep` option must be specified. This is a side effect of more precise dependency tracking in Vue 3.
95+
- [When watching an array, the callback will only trigger when the array is replaced. If you need to to trigger on mutation, the `deep` option must be specified.](/guide/migration/watch.html)
9696
- `<template>` tags with no special directives (`v-if/else-if/else`, `v-for`, or `v-slot`) are now treated as plain elements and will result in a native `<template>` element instead of rendering its inner content.
9797
- In Vue 2.x, application root container's `outerHTML` is replaced with root component template (or eventually compiled to a template, if root component has no template/render option). Vue 3.x now uses application container's `innerHTML` instead - this means the container itself is no longer considered part of the template.
9898

src/guide/migration/v-bind.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,41 @@ badges:
66

77
# {{ $frontmatter.title }} <MigrationBadges :badges="$frontmatter.badges" />
88

9-
In Vue 2, individual bindings always overwrites `v-bind="object"` bindings when used on the same element. In Vue 3, the order of the bindings will affect the rendering result:
9+
## Overview
10+
11+
- **BREAKING**: Order of bindings for v-bind will affect the rendering result.
12+
13+
## Introduction
14+
15+
When dynamically binding attributes on an element, a common scenario involves using both the `v-bind="object"` syntax as well as individual properties in the same element. However, this raises questions as far as the priority of merging.
16+
17+
## 2.x Syntax
18+
19+
In 2.x, if an element has both `v-bind="object"` and an identical individual property defined, the individual property would always overwrite bindings in the `object`.
1020

1121
```html
1222
<!-- template -->
13-
<div id="foo" v-bind="{ id: 'bar' }"></div>
23+
<div id="red" v-bind="{ id: 'blue' }"></div>
1424
<!-- result -->
15-
<div id="bar"></div>
25+
<div id="red"></div>
26+
```
27+
28+
## 3.x Syntax
29+
30+
In 3x, if an element has both `v-bind="object"` and an identical individual property defined, the order of how the bindings are declared determines how they are merged. In other words, rather than assuming developers want the individual property to always override what is defined in the `object`, developers now have more control over the desired merging behavior.
31+
32+
```html
33+
<!-- template -->
34+
<div id="red" v-bind="{ id: 'blue' }"></div>
35+
<!-- result -->
36+
<div id="blue"></div>
1637

1738
<!-- template -->
18-
<div v-bind="{ id: 'bar' }" id="foo"></div>
39+
<div v-bind="{ id: 'blue' }" id="red"></div>
1940
<!-- result -->
20-
<div id="foo"></div>
41+
<div id="red"></div>
2142
```
2243

23-
This is a minor breaking change, but gives the user more control over the desired merging behavior.
44+
## Migration Strategy
45+
46+
If you are relying on this override functionality for `v-bind`, we currently recommending ensuring that your

src/guide/migration/v-if-v-for.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@ badges:
66

77
# {{ $frontmatter.title }} <MigrationBadges :badges="$frontmatter.badges" />
88

9-
The precedence of `v-if` and `v-for` have been flipped when using both on the same element. In Vue 3, `v-if` will always have the higher precedence.
9+
## Overview
1010

11-
It is recommended to avoid using both on the same element due to the syntax ambiguity. Use separate `<template v-if|for>` containers when both are needed at the same time:
11+
- **BREAKING**: If used on the same element, `v-if` will have higher precedence than `v-for`
1212

13-
```html
14-
<template v-for="item in items" :key="item.id">
15-
<div v-if="item.visible">{{ item.text }}</div>
16-
</template>
17-
```
13+
## Introduction
14+
15+
Two of the most commonly used directives in Vue.js are `v-if` and `v-for`. So it's no surprise that there comes a time when developers want to use both together. While this is not a recommended practice, there may be times when this is necessary, so we wanted to provide guidance for how it works.
16+
17+
## 2.x Syntax
18+
19+
In 2.x, when using `v-if` and `v-for` on the same element, `v-for` would take precedence.
20+
21+
## 3.x Syntax
22+
23+
In 3.x, `v-if` will always have the higher precedence than `v-for`.
24+
25+
## Migration Strategy
26+
27+
It is recommended to avoid using both on the same element due to the syntax ambiguity.
28+
29+
Rather than managing this at the template level, one method for accomplishing this is to create a computed property that filters out a list for the visible elements.

src/guide/migration/watch.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Watch on Arrays
3+
badges:
4+
- breaking
5+
---
6+
7+
# {{ $frontmatter.title }} <MigrationBadges :badges="$frontmatter.badges" />
8+
9+
## Overview
10+
11+
- **BREAKING**: When watching an array, the callback will only trigger when the array is replaced. If you need to to trigger on mutation, the `deep` option must be specified.
12+
13+
## 3.x Syntax
14+
15+
When using [the `watch` option](/api/options-data.html#watch) to watch an array, the callback will only trigger when the array is replaced. In other words, the watch callback will no longer be triggered on array mutation. To trigger on mutation, the `deep` option must be specified.
16+
17+
```js
18+
watch: {
19+
bookList: {
20+
handler(val, oldVal) {
21+
console.log('book list changed')
22+
},
23+
deep: true
24+
},
25+
}
26+
```
27+
28+
## Migration Strategy
29+
30+
If you rely on watching array mutations, add the `deep` property to ensure that your callback is triggered correctly.

0 commit comments

Comments
 (0)