Skip to content

Commit a37a85c

Browse files
fix: revise the migration guide for $children, especially the example (vuejs#688)
1 parent a2f811f commit a37a85c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

Diff for: src/guide/migration/children.md

+16-14
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,34 @@ badges:
77

88
## Overview
99

10-
`$children` instance property removed from Vue 3.0 and no longer supported.
10+
The `$children` instance property has been removed from Vue 3.0 and is no longer supported.
1111

1212
## 2.x Syntax
1313

1414
In 2.x, developers could access direct child components of the current instance with `this.$children`:
1515

16-
```html
17-
<div ref="app" id="app">
18-
<img alt="Vue logo" src="./assets/logo.png" width="25%" />
19-
<my-button>Change logo</my-button>
20-
</div>
21-
```
16+
```vue
17+
<template>
18+
<div>
19+
<img alt="Vue logo" src="./assets/logo.png">
20+
<my-button>Change logo</my-button>
21+
</div>
22+
</template>
23+
24+
<script>
25+
import MyButton from './MyButton'
2226
23-
```js
2427
export default {
25-
name: "App",
2628
components: {
27-
MyButton,
29+
MyButton
2830
},
2931
mounted() {
30-
console.log(this.$children); // [VueComponent]
31-
},
32-
};
32+
console.log(this.$children) // [VueComponent]
33+
}
34+
}
3335
</script>
3436
```
3537

3638
## 3.x Update
3739

38-
In 3.x, `$children` property is removed and no longer supported. Instead, if you need to access a child component instance, we recommend using [$refs](/guide/component-template-refs.html#template-refs).
40+
In 3.x, the `$children` property is removed and no longer supported. Instead, if you need to access a child component instance, we recommend using [$refs](/guide/component-template-refs.html#template-refs).

0 commit comments

Comments
 (0)