Skip to content

Commit d995de0

Browse files
nakajmgkazupon
authored andcommitted
Translate Class and Style Bindings (vuejs#158)
1 parent ca07b11 commit d995de0

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/guide/class-and-style.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
---
2-
title: Class and Style Bindings
2+
title: クラスとスタイルのバインディング
33
type: guide
44
order: 6
55
---
66

7-
A common need for data binding is manipulating an element's class list and its inline styles. Since they are both attributes, we can use `v-bind` to handle them: we just need to calculate a final string with our expressions. However, meddling with string concatenation is annoying and error-prone. For this reason, Vue provides special enhancements when `v-bind` is used with `class` and `style`. In addition to strings, the expressions can also evaluate to objects or arrays.
7+
データバインディングに対する共通の必要なことは、要素のクラスリストとインラインスタイルを操作していることです。それらは両方属性になるので、私達はそれらを `v-bind` を使用して処理することができます。私達は私達の式で最終的に文字列を計算する必要があります。しかしながら、文字列の連結に私達が関わることは、迷惑なエラーが発生しやすいです。この理由のため、Vue `v-bind` `class` `style` と一緒に使われるとき、特別な拡張を提供します。文字列に加えて、式はオブジェクトまたは配列も評価することができます。
88

9-
## Binding HTML Classes
9+
## バインディング HTML クラス
1010

11-
### Object Syntax
11+
### オブジェクト構文
1212

13-
We can pass an object to `v-bind:class` to dynamically toggle classes:
13+
私達は、`v-bind:class` に動的にクラスを切り替えるオブジェクトを渡すことが出来ます:
1414

1515
``` html
1616
<div v-bind:class="{ active: isActive }"></div>
1717
```
1818

19-
The above syntax means the presence of the `active` class will be determined by the [truthiness](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) of the data property `isActive`.
19+
上記の構文は `active` クラスが存在するかどうかを、データプロパティの `isActive`[ true と評価される値か](https://developer.mozilla.org/en-US/docs/Glossary/Truthy)によって決まることを意味します。
2020

21-
You can have multiple classes toggled by having more fields in the object. In addition, the `v-bind:class` directive can also co-exist with the plain `class` attribute. So given the following template:
21+
あなたはオブジェクトに複数の項目を持たせることで、複数のクラスを切り替えることが出来ます。加えて、`v-bind:class` ディレクティブはプレーンな `class` 属性と共存できます。 次のようなテンプレートに:
2222

2323
``` html
2424
<div class="static"
2525
v-bind:class="{ active: isActive, 'text-danger': hasError }">
2626
</div>
2727
```
2828

29-
And the following data:
29+
次のようなデータを与えます:
3030

3131
``` js
3232
data: {
@@ -35,15 +35,15 @@ data: {
3535
}
3636
```
3737

38-
It will render:
38+
これは次のようにレンダリングされます:
3939

4040
``` html
4141
<div class="static active"></div>
4242
```
4343

44-
When `isActive` or `hasError` changes, the class list will be updated accordingly. For example, if `hasError` becomes `true`, the class list will become `"static active text-danger"`.
44+
`isActive` `hasError` が変化するとき、クラスリストはそれに応じて更新されます。例えば、`hasError` `true` になった場合、クラスリストは `"static active text-danger"` になります。
4545

46-
The bound object doesn't have to be inline:
46+
インラインでオブジェクトをバインドする必要はありません:
4747

4848
``` html
4949
<div v-bind:class="classObject"></div>
@@ -57,7 +57,7 @@ data: {
5757
}
5858
```
5959

60-
This will render the same result. We can also bind to a [computed property](computed.html) that returns an object. This is a common and powerful pattern:
60+
これは同じ結果をレンダリングします。私たちはオブジェクトを返す[算出プロパティ](computed.html)をバインドすることもできます。これは一般的で強力なパターンです:
6161

6262
``` html
6363
<div v-bind:class="classObject"></div>
@@ -77,9 +77,9 @@ computed: {
7777
}
7878
```
7979

80-
### Array Syntax
80+
### 配列構文
8181

82-
We can pass an array to `v-bind:class` to apply a list of classes:
82+
私達は、`v-bind:class` にクラスのリストを適用する配列を渡すことができます:
8383

8484
``` html
8585
<div v-bind:class="[activeClass, errorClass]">
@@ -91,31 +91,31 @@ data: {
9191
}
9292
```
9393

94-
Which will render:
94+
このようにレンダリングされます:
9595

9696
``` html
9797
<div class="active text-danger"></div>
9898
```
9999

100-
If you would like to also toggle a class in the list conditionally, you can do it with a ternary expression:
100+
条件付きリストでクラスを切り替えたい場合、三項演算子式でそれを行うことができます:
101101

102102
``` html
103103
<div v-bind:class="[isActive ? activeClass : '', errorClass]">
104104
```
105105

106-
This will always apply `errorClass`, but will only apply `activeClass` when `isActive` is `true`.
106+
これは常に `errorClass` が適用されますが、`isActive``true` のときにだけ `activeClass` クラスが適用されます。
107107

108-
However, this can be a bit verbose if you have multiple conditional classes. That's why it's also possible to use the object syntax inside array syntax:
108+
しかしながら、これは複数条件のクラスがある場合は少し冗長です。なので配列構文内部ではオブジェクト構文も使えます:
109109

110110
``` html
111111
<div v-bind:class="[{ active: isActive }, errorClass]">
112112
```
113113

114-
## Binding Inline Styles
114+
## バインディングインラインスタイル
115115

116-
### Object Syntax
116+
### オブジェクト構文
117117

118-
The object syntax for `v-bind:style` is pretty straightforward - it looks almost like CSS, except it's a JavaScript object. You can use either camelCase or kebab-case for the CSS property names:
118+
`v-bind:style`向けのオブジェクト構文は非常に簡単です。それは、JavaScript オブジェクトを除いては、ほとんど CSS のように見えます。CSS プロパティ名に対して、キャメルケース (caml-case) またはケバブケース (kebab-case) のどちらでも使用することができます:
119119

120120
``` html
121121
<div v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }"></div>
@@ -127,7 +127,7 @@ data: {
127127
}
128128
```
129129

130-
It is often a good idea to bind to a style object directly so that the template is cleaner:
130+
テンプレートがクリーンになれるようにするために、直接 style オブジェクトにバインドするのは、よいアイディアです:
131131

132132
``` html
133133
<div v-bind:style="styleObject"></div>
@@ -141,16 +141,16 @@ data: {
141141
}
142142
```
143143

144-
Again, the object syntax is often used in conjunction with computed properties that return objects.
144+
また、オブジェクト構文はよくオブジェクトを返す算出プロパティと併せて使用されます。
145145

146-
### Array Syntax
146+
### 配列構文
147147

148-
The array syntax for `v-bind:style` allows you to apply multiple style objects to the same element:
148+
`v-bind:style` 向けの配列構文は、同じ要素に複数のスタイルオブジェクトを適用することができます:
149149

150150
``` html
151151
<div v-bind:style="[baseStyles, overridingStyles]">
152152
```
153153

154-
### Auto-prefixing
154+
### 自動プリフィックス
155155

156-
When you use a CSS property that requires vendor prefixes in `v-bind:style`, for example `transform`, Vue will automatically detect and add appropriate prefixes to the applied styles.
156+
`v-bind:style` でベンダー接頭辞を要求される CSS プロパティを使用するとき、例えば、`transform` においては、Vue.js は自動的に検出し、適用されるスタイルに適切な接頭辞を追加します。

0 commit comments

Comments
 (0)