Skip to content

Commit 2450ef9

Browse files
committed
docs: translate api reference > options > data
1 parent 9727237 commit 2450ef9

File tree

1 file changed

+64
-63
lines changed

1 file changed

+64
-63
lines changed

src/api/options-data.md

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
## data
44

5-
- **Type:** `Function`
5+
- **:** `Function`
66

7-
- **Details:**
7+
- **詳細:**
88

9-
The function that returns a data object for the component instance. In `data`, we don't recommend to observe objects with their own stateful behavior like browser API objects and prototype properties. A good idea would be to have here just a plain object that represents component data.
9+
コンポーネントインスタンスのデータオブジェクトを返す関数です。 `data` では、ブラウザの API オブジェクトや prototype プロパティのような独自のステートフルな振る舞いをするオブジェクトを監視することはお勧めしません。よい考え方としては、コンポーネントのデータを表すただのプレーンオブジェクトをここで持つべきです。
1010

11-
Once observed, you can no longer add reactive properties to the root data object. It is therefore recommended to declare all root-level reactive properties upfront, before creating the instance.
11+
一度監視されると、ルートのデータオブジェクトにリアクティブなプロパティを追加することはできなくなります。そのため、インスタンスを作成する前に、すべてのルートレベルのリアクティブプロパティを前もって宣言しておくことをお勧めします。
1212

13-
After the instance is created, the original data object can be accessed as `vm.$data`. The component instance also proxies all the properties found on the data object, so `vm.a` will be equivalent to `vm.$data.a`.
13+
インスタンスが作成された後に、`vm.$data` として元のデータオブジェクトアクセスできます。コンポーネントインスタンスは、データオブジェクトのすべてのプロパティをプロキシするため、`vm.a` `vm.$data.a` と同じになります。
1414

15-
Properties that start with `_` or `$` will **not** be proxied on the component instance because they may conflict with Vue's internal properties and API methods. You will have to access them as `vm.$data._property`.
15+
Vue の内部プロパティや API メソッドと競合する可能性があるため、`_` `$` からはじまるプロパティはコンポーネントインスタンスで **プロキシされません**。これらは `vm.$data._property` としてアクセスする必要があります。
1616

17-
- **Example:**
17+
- **:**
1818

1919
```js
20-
// direct instance creation
20+
// 直接インスタンスを生成
2121
const data = { a: 1 }
2222

23-
// The object is added to a component instance
23+
// コンポーネントインスタンスにオブジェクトを追加
2424
const vm = createApp({
2525
data() {
2626
return data
@@ -30,48 +30,48 @@
3030
console.log(vm.a) // => 1
3131
```
3232

33-
Note that if you use an arrow function with the `data` property, `this` won't be the component's instance, but you can still access the instance as the function's first argument:
33+
`data` プロパティでアロー関数を使う場合、`this` はコンポーネントのインスタンスになりませんが、関数の第 1 引数としてそのインスタンスにアクセスできるということは忘れないでください。
3434

3535
```js
3636
data: vm => ({ a: vm.myProp })
3737
```
3838

39-
- **See also:** [Reactivity in Depth](../guide/reactivity.html)
39+
- **参照:** [リアクティビティの探求](../guide/reactivity.html)
4040

4141
## props
4242

43-
- **Type:** `Array<string> | Object`
43+
- **:** `Array<string> | Object`
4444

45-
- **Details:**
45+
- **詳細:**
4646

47-
A list/hash of attributes that are exposed to accept data from the parent component. It has an Array-based simple syntax and an alternative Object-based syntax that allows advanced configurations such as type checking, custom validation and default values.
47+
親コンポーネントからデータを受け取るために公開されている属性のリストかハッシュです。配列ベースの単純な構文と、型チェックやカスタムバリデーション、デフォルト値などの高度な設定ができるオブジェクトベースの構文があります。
4848

49-
With Object-based syntax, you can use following options:
49+
オブジェクトベースの構文では、以下のオプションを使用できます:
5050

51-
- `type`: can be one of the following native constructors: `String`, `Number`, `Boolean`, `Array`, `Object`, `Date`, `Function`, `Symbol`, any custom constructor function or an array of those. Will check if a prop has a given type, and will throw a warning if it doesn't. [More information](../guide/component-props.html#prop-types) on prop types.
51+
- `type`: 次のネイティブコンストラクタのいずれかになります: `String``Number``Boolean``Array``Object``Date``Function``Symbol`、任意のカスタムコンストラクタ関数、またはそれらの配列。プロパティが与えられた型を持っているか確認して、そうでない場合には警告を出します。プロパティの型について [詳細な情報](../guide/component-props.html#プロパティの型) を参照してください。
5252
- `default`: `any`
53-
Specifies a default value for the prop. If the prop is not passed, this value will be used instead. Object or array defaults must be returned from a factory function.
53+
プロパティのデフォルト値を指定します。プロパティが渡されない場合、この値が変わりに使用されます。オブジェクト、または配列のデフォルト値はファクトリ関数から返さなければなりません。
5454
- `required`: `Boolean`
55-
Defines if the prop is required. In a non-production environment, a console warning will be thrown if this value is truthy and the prop is not passed.
55+
プロパティが必須かどうかを定義します。非本番環境では、この値が true ならプロパティが渡されない場合、コンソールに警告を出します。
5656
- `validator`: `Function`
57-
Custom validator function that takes the prop value as the sole argument. In a non-production environment, a console warning will be thrown if this function returns a falsy value (i.e. the validation fails). You can read more about prop validation [here](../guide/component-props.html#prop-validation).
57+
プロパティの値を唯一の引数として受け取るカスタムバリデータ関数です。非本番環境では、この関数が false を返す場合(例えばバリデーションが失敗した場合)、コンソールに警告を出します。プロパティのバリデーションについて、詳しくは [こちら](../guide/component-props.html#プロパティのバリデーション) を参照してください。
5858

59-
- **Example:**
59+
- **:**
6060

6161
```js
6262
const app = createApp({})
6363

64-
// simple syntax
64+
// 単純な構文
6565
app.component('props-demo-simple', {
6666
props: ['size', 'myMessage']
6767
})
6868

69-
// object syntax with validation
69+
// バリデーションありのオブジェクト構文
7070
app.component('props-demo-advanced', {
7171
props: {
72-
// type check
72+
// 型チェック
7373
height: Number,
74-
// type check plus other validations
74+
// 型チェックと追加のバリデーション
7575
age: {
7676
type: Number,
7777
default: 0,
@@ -84,39 +84,39 @@
8484
})
8585
```
8686

87-
- **See also:** [Props](../guide/component-props.html)
87+
- **参照:** [プロパティ](../guide/component-props.html)
8888

8989
## computed
9090

91-
- **Type:** `{ [key: string]: Function | { get: Function, set: Function } }`
91+
- **:** `{ [key: string]: Function | { get: Function, set: Function } }`
9292

93-
- **Details:**
93+
- **詳細:**
9494

95-
Computed properties to be mixed into the component instance. All getters and setters have their `this` context automatically bound to the component instance.
95+
コンポーネントのインスタンスに混入される算出プロパティです。すべてのゲッターとセッターは、そのコンポーネントのインスタンスへ自動的に束縛される `this` コンテキストを持っています。
9696

97-
Note that if you use an arrow function with a computed property, `this` won't be the component's instance, but you can still access the instance as the function's first argument:
97+
算出プロパティでアロー関数を使う場合、`this` はコンポーネントのインスタンスになりませんが、関数の第 1 引数としてそのインスタンスにアクセスできるということは忘れないでください。:
9898

9999
```js
100100
computed: {
101101
aDouble: vm => vm.a * 2
102102
}
103103
```
104104

105-
Computed properties are cached, and only re-computed on reactive dependency changes. Note that if a certain dependency is out of the instance's scope (i.e. not reactive), the computed property will **not** be updated.
105+
算出プロパティはキャッシュされ、リアクティブな依存の変更でのみ再計算されます。ある依存がインスタンスのスコープ外にある場合(例えばリアクティブでない場合)、算出プロパティは **更新されない** ことに注意してください。
106106

107-
- **Example:**
107+
- **:**
108108

109109
```js
110110
const app = createApp({
111111
data() {
112112
return { a: 1 }
113113
},
114114
computed: {
115-
// get only
115+
// 取得のみ
116116
aDouble() {
117117
return this.a * 2
118118
},
119-
// both get and set
119+
// 取得と値の設定の両方
120120
aPlus: {
121121
get() {
122122
return this.a + 1
@@ -135,21 +135,21 @@
135135
console.log(vm.aDouble) // => 4
136136
```
137137

138-
- **See also:** [Computed Properties](../guide/computed.html)
138+
- **参照:** [算出プロパティ](../guide/computed.html)
139139

140140
## methods
141141

142-
- **Type:** `{ [key: string]: Function }`
142+
- **:** `{ [key: string]: Function }`
143143

144-
- **Details:**
144+
- **詳細:**
145145

146-
Methods to be mixed into the component instance. You can access these methods directly on the VM instance, or use them in directive expressions. All methods will have their `this` context automatically bound to the component instance.
146+
コンポーネントのインスタンスに混入されるメソッドです。これらのメソッドは、VM インスタンスで直接アクセスすることも、ディレクティブ式で使うこともできます。すべてのメソッドは、コンポーネントインスタンスに自動的に束縛された `this` コンテキストを持ちます。
147147

148148
:::tip Note
149-
Note that **you should not use an arrow function to define a method** (e.g. `plus: () => this.a++`). The reason is arrow functions bind the parent context, so `this` will not be the component instance as you expect and `this.a` will be undefined.
149+
**メソッドの定義にアロー関数を使ってはいけない** ということに注意してください(例: `plus: () => this.a++`)。その理由は、アロー関数が親のコンテキストを束縛するため、`this` が期待したとおりのコンポーネントインスタンスにならないのと、`this.a` が未定義になるからです。
150150
:::
151151

152-
- **Example:**
152+
- **:**
153153

154154
```js
155155
const app = createApp({
@@ -169,17 +169,17 @@
169169
console.log(vm.a) // => 2
170170
```
171171

172-
- **See also:** [Event Handling](../guide/events.html)
172+
- **参照:** [イベントハンドリング](../guide/events.html)
173173

174174
## watch
175175

176-
- **Type:** `{ [key: string]: string | Function | Object | Array}`
176+
- **:** `{ [key: string]: string | Function | Object | Array}`
177177

178-
- **Details:**
178+
- **詳細:**
179179

180-
An object where keys are reactive properties to watch — examples include [data](/api/options-data.html#data-2) or [computed](/api/options-data.html#computed) properties — and values are the corresponding callbacks. The value can also be a string of a method name, or an Object that contains additional options. The component instance will call `$watch()` for each entry in the object at instantiation. See [$watch](instance-methods.html#watch) for more information about the `deep`, `immediate` and `flush` options.
180+
キーが監視するリアクティブなプロパティで、例えば [data](/api/options-data.html#data-2) または [computed](/api/options-data.html#computed) プロパティを含み、値が対応するコールバックとなるオブジェクトです。値はメソッド名の文字列や、追加のオプションを含むオブジェクトを指定することもできます。コンポーネントインスタンスはインスタンス化の際に、オブジェクトの各エントリに対して `$watch()` を呼び出します。`deep``immediate`、または `flush` オプションの詳細については [$watch](instance-methods.html#watch) を参照してください。
181181

182-
- **Example:**
182+
- **:**
183183

184184
```js
185185
const app = createApp({
@@ -195,31 +195,31 @@
195195
}
196196
},
197197
watch: {
198-
// watching top-level property
198+
// トップレベルのプロパティを監視
199199
a(val, oldVal) {
200200
console.log(`new: ${val}, old: ${oldVal}`)
201201
},
202-
// string method name
202+
// メソッド名の文字列
203203
b: 'someMethod',
204-
// the callback will be called whenever any of the watched object properties change regardless of their nested depth
204+
// 監視しているオブジェクトのプロパティが変更されると入れ子の深さに関わらずコールバックが呼び出されます
205205
c: {
206206
handler(val, oldVal) {
207207
console.log('c changed')
208208
},
209209
deep: true
210210
},
211-
// watching a single nested property:
211+
// 入れ子になった 1 つのプロパティを監視
212212
'c.d': function (val, oldVal) {
213213
// do something
214214
},
215-
// the callback will be called immediately after the start of the observation
215+
// 監視が開始した直後にコールバックが呼び出されます
216216
e: {
217217
handler(val, oldVal) {
218218
console.log('e changed')
219219
},
220220
immediate: true
221221
},
222-
// you can pass array of callbacks, they will be called one-by-one
222+
// コールバックの配列を渡せて、それらは 1 つずつ呼び出されます
223223
f: [
224224
'handle1',
225225
function handle2(val, oldVal) {
@@ -249,41 +249,42 @@
249249
```
250250

251251
::: tip Note
252-
Note that _you should not use an arrow function to define a watcher_ (e.g. `searchQuery: newValue => this.updateAutocomplete(newValue)`). The reason is arrow functions bind the parent context, so `this` will not be the component instance as you expect and `this.updateAutocomplete` will be undefined.
252+
_ウォッチャの定義にアロー関数を使ってはいけない_ ということに注意してください(例: `searchQuery: newValue => this.updateAutocomplete(newValue)`)。その理由は、アロー関数が親のコンテキストを束縛するため、`this` は期待したとおりのコンポーネントインスタンスにはならないのと、`this.updateAutocomplete` が未定義になるからです。
253253
:::
254254

255-
- **See also:** [Watchers](../guide/computed.html#watchers)
255+
256+
- **参照:** [ウォッチャ](../guide/computed.html#ウォッチャ)
256257

257258
## emits
258259

259-
- **Type:** `Array<string> | Object`
260+
- **:** `Array<string> | Object`
260261

261-
- **Details:**
262+
- **詳細:**
262263

263-
A list/hash of custom events that can be emitted from the component. It has an Array-based simple syntax and an alternative Object-based syntax that allows to configure an event validation.
264+
コンポーネントから発行されるカスタムイベントのリストやハッシュです。配列ベースの単純な構文と、イベントのバリデーションを設定できるオブジェクトベースの構文があります。
264265

265-
In Object-based syntax, the value of each property can either be `null` or a validator function. The validation function will receive the additional arguments passed to the `$emit` call. For example, if `this.$emit('foo', 1)` is called, the corresponding validator for `foo` will receive the argument `1`. The validator function should return a boolean to indicate whether the event arguments are valid.
266+
オブジェクトベースの構文では、各プロパティの値は `null` か、バリデーション関数のどちらかです。バリデーション関数は `$emit` の呼び出しに渡された追加の引数を受け取ります。例えば、`this.$emit('foo', 1)` が呼び出された場合、`foo` に対応するバリデータは、引数 `1` を受け取ります。バリデーション関数は、イベントの引数が妥当かどうかを示すブール値を返す必要があります。
266267

267-
- **Usage:**
268+
- **使用方法:**
268269

269270
```js
270271
const app = createApp({})
271272

272-
// Array syntax
273+
// 配列の構文
273274
app.component('todo-item', {
274275
emits: ['check'],
275276
created() {
276277
this.$emit('check')
277278
}
278279
})
279280

280-
// Object syntax
281+
// オブジェクトの構文
281282
app.component('reply-form', {
282283
emits: {
283-
// no validation
284+
// バリデーションなし
284285
click: null,
285286

286-
// with validation
287+
// バリデーションあり
287288
submit: payload => {
288289
if (payload.email && payload.password) {
289290
return true
@@ -297,7 +298,7 @@
297298
```
298299

299300
::: tip Note
300-
Events listed in the `emits` option **will not** be inherited by the root element of the component and also will be excluded from the `$attrs` property.
301+
`emits` オプションにリスト化されたイベントは、コンポーネントのルート要素には **継承されません**。また、`$attrs` プロパティからも除外されます。
301302
:::
302303

303-
* **See also:** [Attribute Inheritance](../guide/component-attrs.html#attribute-inheritance)
304+
* **参照:** [属性の継承](../guide/component-attrs.html#属性の継承)

0 commit comments

Comments
 (0)