Skip to content

Revise the migration guide for $children, especially the example #688

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 1 commit into from
Nov 11, 2020
Merged
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
30 changes: 16 additions & 14 deletions src/guide/migration/children.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@ badges:

## Overview

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

## 2.x Syntax

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

```html
<div ref="app" id="app">
<img alt="Vue logo" src="./assets/logo.png" width="25%" />
<my-button>Change logo</my-button>
</div>
```
```vue
<template>
<div>
<img alt="Vue logo" src="./assets/logo.png">
<my-button>Change logo</my-button>
</div>
</template>

<script>
import MyButton from './MyButton'

```js
export default {
name: "App",
components: {
MyButton,
MyButton
},
mounted() {
console.log(this.$children); // [VueComponent]
},
};
console.log(this.$children) // [VueComponent]
}
}
</script>
```

## 3.x Update

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).
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).