Skip to content

Commit f03a5e7

Browse files
committed
docs: translate h() args to slot section
1 parent 9d8cb97 commit f03a5e7

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/guide/render-function.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ h(
166166
)
167167
```
168168

169-
If there are no props then the children can usually be passed as the second argument. In cases where that would be ambiguous, `null` can be passed as the second argument to keep the children as the third argument.
169+
props がない場合は、通常 children を第2引数として渡すことができます。それがあいまいな場合は、 `null` を第2引数として渡して、 children を第3引数にしておけます。
170170

171171
## 完全な例
172172

173-
この知識によって、書き始めたコンポーネントを今では完成させることができます:
173+
この知識によって、今度は書き始めたコンポーネントを完成させることができます:
174174

175175
```js
176176
const { createApp, h } = Vue
@@ -246,17 +246,17 @@ render() {
246246
}
247247
```
248248

249-
## Creating Component VNodes
249+
## コンポーネントの VNodes を作る
250250

251-
To create a VNode for a component, the first argument passed to `h` should be the component itself:
251+
コンポーネントの VNode を作るためには、 `h` の第1引数にコンポーネントそのものを渡します:
252252

253253
```js
254254
render() {
255255
return h(ButtonCounter)
256256
}
257257
```
258258

259-
If we need to resolve a component by name then we can call `resolveComponent`:
259+
コンポーネントを名前解決する必要がある場合は、 `resolveComponent` で呼び出せます:
260260

261261
```js
262262
const { h, resolveComponent } = Vue
@@ -269,12 +269,12 @@ render() {
269269
}
270270
```
271271

272-
`resolveComponent` is the same function that templates use internally to resolve components by name.
272+
`resolveComponent` は、テンプレートがコンポーネントを名前解決するために内部的に使っているものと同じ関数です。
273273

274-
A `render` function will normally only need to use `resolveComponent` for components that are [registered globally](/guide/component-registration.html#global-registration). [Local component registration](/guide/component-registration.html#local-registration) can usually be skipped altogether. Consider the following example:
274+
`render` 関数は通常、 [グローバルに登録された](/guide/component-registration.html#グローバル登録) コンポーネントにだけ `resolveComponent` を使う必要があります。 [ローカルのコンポーネント登録](/guide/component-registration.html#ローカル登録) は通常、完全に省略できます。次のような例を考えてみましょう:
275275

276276
```js
277-
// We can simplify this
277+
// これを単純化してみると
278278
components: {
279279
ButtonCounter
280280
},
@@ -283,7 +283,7 @@ render() {
283283
}
284284
```
285285

286-
Rather than registering a component by name and then looking it up we can use it directly instead:
286+
コンポーネントの名前を登録して、それを調べるというよりも、直接使うことができます:
287287

288288
```js
289289
render() {
@@ -319,7 +319,7 @@ render() {
319319
}
320320
```
321321

322-
In a template it can be useful to use a `<template>` tag to hold a `v-if` or `v-for` directive. When migrating to a `render` function, the `<template>` tag is no longer required and can be discarded.
322+
テンプレートでは、 `<template>` タグを使って `v-if` `v-for` ディレクティブを当てておくと便利です。 `render` 関数に移行するときには、 `<template>` タグは不要となり、破棄することができます。
323323

324324
### `v-model`
325325

@@ -350,7 +350,7 @@ render() {
350350

351351
#### イベント修飾子
352352

353-
For the `.passive`, `.capture`, and `.once` event modifiers, they can be concatenated after the event name using camel case.
353+
`.passive``.capture``.once` イベント修飾子は、キャメルケースを使ってイベント名の後につなげます。
354354

355355
例えば:
356356

@@ -372,8 +372,8 @@ render() {
372372
| `.stop` | `event.stopPropagation()` |
373373
| `.prevent` | `event.preventDefault()` |
374374
| `.self` | `if (event.target !== event.currentTarget) return` |
375-
| Keys:<br>e.g. `.enter` | `if (event.key !== 'Enter') return`<br><br>Change `'Enter'` to the appropriate [key](http://keycode.info/) |
376-
| Modifier Keys:<br>`.ctrl`, `.alt`, `.shift`, `.meta` | `if (!event.ctrlKey) return`<br><br>Likewise for `altKey`, `shiftKey`, and `metaKey` |
375+
| キー:<br> `.enter` | `if (event.key !== 'Enter') return`<br><br>`'Enter'` キーを適切な [キー](http://keycode.info/) に変更 |
376+
| 修飾キー:<br>`.ctrl`, `.alt`, `.shift`, `.meta` | `if (!event.ctrlKey) return`<br><br>`altKey``shiftKey``metaKey` も同様 |
377377

378378
これらすべての修飾子を一緒に使った例がこちらです:
379379

@@ -418,7 +418,7 @@ render() {
418418
}
419419
```
420420

421-
For component VNodes, we need to pass the children to `h` as an object rather than an array. Each property is used to populate the slot of the same name:
421+
コンポーネントの VNodes の場合、引数 children を配列ではなくオブジェクトとして `h` に渡す必要があります。各プロパティは、同名のスロットに移植するために使われます:
422422

423423
```js
424424
render() {
@@ -437,23 +437,23 @@ render() {
437437
}
438438
```
439439

440-
The slots are passed as functions, allowing the child component to control the creation of each slot's contents. Any reactive data should be accessed within the slot function to ensure that it's registered as a dependency of the child component and not the parent. Conversely, calls to `resolveComponent` should be made outside the slot function, otherwise they'll resolve relative to the wrong component:
440+
スロットは関数として渡され、子コンポーネントが各スロットのコンテンツの作成を制御できるようになっています。リアクティブなデータは、親コンポーネントではなく子コンポーネントの依存関係として登録されるように、スロット関数内でアクセスする必要があります。逆に `resolveComponent` の呼び出しは、スロット関数の外で行うべきで、そうしないと間違ったコンポーネントへの相対的な解決になってしまいます:
441441

442442
```js
443443
// `<MyButton><MyIcon :name="icon" />{{ text }}</MyButton>`
444444
render() {
445-
// Calls to resolveComponent should be outside the slot function
445+
// resolveComponent の呼び出しはスロット関数の外側でなければなりません
446446
const Button = resolveComponent('MyButton')
447447
const Icon = resolveComponent('MyIcon')
448448

449449
return h(
450450
Button,
451451
null,
452452
{
453-
// Use an arrow function to preserve the `this` value
453+
// アロー関数を使って `this` の値を保持します
454454
default: (props) => {
455-
// Reactive properties should be read inside the slot function
456-
// so that they become dependencies of the child's rendering
455+
// リアクティブなプロパティは、子のレンダリングの依存関係になるように
456+
// スロット関数の内側で読み込む必要があります
457457
return [
458458
h(Icon, { name: this.icon }),
459459
this.text
@@ -464,27 +464,27 @@ render() {
464464
}
465465
```
466466

467-
If a component receives slots from its parent, they can be passed on directly to a child component:
467+
コンポーネントが親からスロットを受け取った場合、そのスロットを子のコンポーネントに直接渡せます:
468468

469469
```js
470470
render() {
471471
return h(Panel, null, this.$slots)
472472
}
473473
```
474474

475-
They can also be passed individually or wrapped as appropriate:
475+
また、必要に応じて個別に渡したり、ラップすることもできます:
476476

477477
```js
478478
render() {
479479
return h(
480480
Panel,
481481
null,
482482
{
483-
// If we want to pass on a slot function we can
483+
// スロット関数を渡したい場合は次のようになります
484484
header: this.$slots.header,
485485

486-
// If we need to manipulate the slot in some way
487-
// then we need to wrap it in a new function
486+
// スロットを何らかの方法で操作する必要がある場合は、
487+
// 新しい関数でそれをラップする必要があります
488488
default: (props) => {
489489
const children = this.$slots.default ? this.$slots.default(props) : []
490490

0 commit comments

Comments
 (0)