You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Despite the existence of props and events, sometimes you might still need to directly access a child component in JavaScript. To achieve this you can assign a reference ID to the child component or HTML element using the `ref`attribute. For example:
5
+
プロパティやイベントが存在するにもかかわらず、 JavaScript で子コンポーネントに直接アクセスしなければならない場合があります。それを達成するために、`ref`属性を使うことで子コンポーネントや HTML 要素に参照 ID を割り当てられます。例えば、以下のようになります:
6
6
7
7
```html
8
8
<inputref="input" />
9
9
```
10
10
11
-
This may be useful when you want to, for example, programmatically focus this input on component mount:
`$refs`are only populated after the component has been rendered. It is only meant as an escape hatch for direct child manipulation - you should avoid accessing `$refs`from within templates or computed properties.
0 commit comments