Skip to content

Commit 7410b0a

Browse files
committed
docs: translate 'Watching Template Refs' section
1 parent cdb7054 commit 7410b0a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/guide/composition-api-template-refs.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default {
5353
}
5454
```
5555

56-
## Usage inside `v-for`
56+
## `v-for` 内部での使用
5757

5858
コンポジション API のテンプレート参照を `v-for` 内部で使う場合、特別な処理はされません。代わりに、関数を使って ref に独自処理を行うようにします。
5959

@@ -86,11 +86,11 @@ export default {
8686
</script>
8787
```
8888

89-
## Watching Template Refs
89+
## テンプレート参照の監視
9090

91-
Watching a template ref for changes can be an alternative to the use of lifecycle hooks that was demonstrated in the previous examples.
91+
変更のためテンプレート参照の監視をすることは、前の例で説明したライフサイクルフックの使い方に代わる方法です。
9292

93-
But a key difference to lifecycle hooks is that `watch()` and `watchEffect()` effects are run *before* the DOM is mounted or updated so the template ref hasn't been updated when the watcher runs the effect:
93+
しかしライフサイクルフックとの重要な違いは、`watch()` `watchEffect()` の作用は、DOM がマウントされたり更新されたりする *前に* 実行されるので、ウォッチャが作用を実行したときには、テンプレート参照は更新されていないということです:
9494

9595
```vue
9696
<template>
@@ -105,8 +105,8 @@ But a key difference to lifecycle hooks is that `watch()` and `watchEffect()` ef
105105
const root = ref(null)
106106
107107
watchEffect(() => {
108-
// This effect runs before the DOM is updated, and consequently,
109-
// the template ref does not hold a reference to the element yet.
108+
// この作用は DOM が更新される前に実行され、
109+
// 結果的にテンプレート参照は、まだ要素への参照を保持していません。
110110
console.log(root.value) // => null
111111
})
112112
@@ -118,7 +118,7 @@ But a key difference to lifecycle hooks is that `watch()` and `watchEffect()` ef
118118
</script>
119119
```
120120

121-
Therefore, watchers that use template refs should be defined with the `flush: 'post'` option. This will run the effect *after* the DOM has been updated and ensure that the template ref stays in sync with the DOM and references the correct element.
121+
そのため、テンプレート参照を使うウォッチャは、 `flush: 'post'` オプションをつけて定義する必要があります。これにより、DOM が更新された *あとに* 作用が実行され、テンプレート参照が DOM と同期して、正しい要素を参照するようになります。
122122

123123
```vue
124124
<template>
@@ -147,4 +147,4 @@ Therefore, watchers that use template refs should be defined with the `flush: 'p
147147
</script>
148148
```
149149

150-
* See also: [Computed and Watchers](./reactivity-computed-watchers.html#effect-flush-timing)
150+
* 参照: [算出プロパティとウォッチ](./reactivity-computed-watchers.html#作用フラッシュのタイミング)

0 commit comments

Comments
 (0)