Skip to content

Commit bbe7dd9

Browse files
t0yoheit0yohei
and
t0yohei
authored
translate Conditional Rendering (#300)
Co-authored-by: t0yohei <[email protected]>
1 parent c4613f8 commit bbe7dd9

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/guide/essentials/conditional.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Conditional Rendering
1+
# 条件付きレンダリング
22

33
<div class="options-api">
44
<VueSchoolLink href="https://vueschool.io/lessons/conditional-rendering-in-vue-3" title="Free Vue.js Conditional Rendering Lesson"/>
@@ -15,15 +15,15 @@ const awesome = ref(true)
1515

1616
## `v-if`
1717

18-
The directive `v-if` is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy value.
18+
`v-if` ディレクティブは、ブロックを条件に応じてレンダリングしたい場合に使用されます。ブロックは、ディレクティブの式が真を返す場合のみレンダリングされます。
1919

2020
```vue-html
2121
<h1 v-if="awesome">Vue is awesome!</h1>
2222
```
2323

2424
## `v-else`
2525

26-
You can use the `v-else` directive to indicate an "else block" for `v-if`:
26+
`v-if` に対して "else block" を示すために、`v-else` ディレクティブを使用できます:
2727

2828
```vue-html
2929
<button @click="awesome = !awesome">Toggle</button>
@@ -49,11 +49,11 @@ You can use the `v-else` directive to indicate an "else block" for `v-if`:
4949

5050
</div>
5151

52-
A `v-else` element must immediately follow a `v-if` or a `v-else-if` element - otherwise it will not be recognized.
52+
`v-else` 要素は、`v-if` または `v-else-if` 要素の直後になければなりません。それ以外の場合は認識されません。
5353

5454
## `v-else-if`
5555

56-
The `v-else-if`, as the name suggests, serves as an "else if block" for `v-if`. It can also be chained multiple times:
56+
`v-else-if` は、名前が示唆するように、`v-if`"else if block" として機能します。また、複数回連結することもできます:
5757

5858
```vue-html
5959
<div v-if="type === 'A'">
@@ -70,11 +70,11 @@ The `v-else-if`, as the name suggests, serves as an "else if block" for `v-if`.
7070
</div>
7171
```
7272

73-
Similar to `v-else`, a `v-else-if` element must immediately follow a `v-if` or a `v-else-if` element.
73+
`v-else` と同様に、`v-else-if` 要素は `v-if` 要素または `v-else-if` 要素の直後になければなりません。
7474

75-
## `v-if` on `<template>`
75+
## `<template>` での `v-if`
7676

77-
Because `v-if` is a directive, it has to be attached to a single element. But what if we want to toggle more than one element? In this case we can use `v-if` on a `<template>` element, which serves as an invisible wrapper. The final rendered result will not include the `<template>` element.
77+
`v-if` はディレクティブなので、単一の要素に付加する必要があります。しかし、1 要素よりも多くの要素と切り替えたい場合はどうでしょうか?このケースでは、非表示ラッパー (wrapper) として提供される、`<template>` 要素で `v-if` を使用できます。最終的にレンダリングされる結果は、`<template>` 要素は含まれません。
7878

7979
```vue-html
8080
<template v-if="ok">
@@ -84,34 +84,34 @@ Because `v-if` is a directive, it has to be attached to a single element. But wh
8484
</template>
8585
```
8686

87-
`v-else` and `v-else-if` can also be used on `<template>`.
87+
`v-else` `v-else-if` `<template>` でも使用可能です。
8888

8989
## `v-show`
9090

91-
Another option for conditionally displaying an element is the `v-show` directive. The usage is largely the same:
91+
条件的に要素を表示するための別のオプションは `v-show` です。使用方法はほとんど同じです:
9292

9393
```vue-html
9494
<h1 v-show="ok">Hello!</h1>
9595
```
9696

97-
The difference is that an element with `v-show` will always be rendered and remain in the DOM; `v-show` only toggles the `display` CSS property of the element.
97+
違いは `v-show` による要素は常レンダリングされて DOM に残るということです。`v-show` はシンプルに要素の `display` CSS プロパティを切り替えます。
9898

99-
`v-show` doesn't support the `<template>` element, nor does it work with `v-else`.
99+
`v-show` `<template>` 要素をサポートせず、`v-else` とも連動しないということに注意してください。
100100

101101
## `v-if` vs `v-show`
102102

103-
`v-if` is "real" conditional rendering because it ensures that event listeners and child components inside the conditional block are properly destroyed and re-created during toggles.
103+
`v-if` は、イベントリスナと子コンポーネント内部の条件ブロックが適切に破棄され、そして切り替えられるまでの間再作成されるため、”リアル”な条件レンダリングです。
104104

105-
`v-if` is also **lazy**: if the condition is false on initial render, it will not do anything - the conditional block won't be rendered until the condition becomes true for the first time.
105+
`v-if` はまた **遅延レンダリング (lazy)** でもあります。 初期表示において状態が false の場合、何もしません。つまり条件付きブロックは、条件が最初に true になるまでレンダリングされません。
106106

107-
In comparison, `v-show` is much simpler - the element is always rendered regardless of initial condition, with CSS-based toggling.
107+
一方で、`v-show` はとてもシンプルです。要素は初期条件に関わらず常にレンダリングされ、シンプルな CSS ベースの切り替えによって表示されます。
108108

109-
Generally speaking, `v-if` has higher toggle costs while `v-show` has higher initial render costs. So prefer `v-show` if you need to toggle something very often, and prefer `v-if` if the condition is unlikely to change at runtime.
109+
一般的に、`v-if` はより高い切り替えコストを持っているのに対して、 `v-show` はより高い初期レンダリングコストを持っています。 そのため、とても頻繁に何かを切り替える必要があれば `v-show` を選び、条件が実行時に変更することがほとんどない場合は、`v-if` を選びます。
110110

111-
## `v-if` with `v-for`
111+
## `v-if` `v-for`
112112

113113
::: warning Note
114-
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [style guide](/style-guide/rules-essential.html#avoid-v-if-with-v-for) for details.
114+
暗黙的な優先順位により、 `v-if` `v-for` を同じ要素で利用することは **推奨されません**。 詳細については [スタイルガイド](/style-guide/rules-essential.html#v-for-と一緒に-v-if-を使うのを避ける-) を参照ください。
115115
:::
116116

117-
When `v-if` and `v-for` are both used on the same element, `v-if` will be evaluated first. See the [list rendering guide](list#v-for-with-v-if) for details.
117+
`v-if` `v-for` が同じ要素に両方つかわれる場合、 `v-if` が先に評価されます。詳細については [リストレンダリングのガイド](list.html#v-for--v-if) を参照してください。

0 commit comments

Comments
 (0)