1
1
---
2
- title : Data Option
2
+ title : Data オプション
3
3
badges :
4
4
- breaking
5
5
---
6
6
7
7
# {{ $frontmatter.title }} <MigrationBadges :badges =" $frontmatter.badges " />
8
8
9
- ## Overview
9
+ ## 概要
10
10
11
- - ** BREAKING ** : ` data ` component option declaration no longer accepts a plain JavaScript ` object ` and expects a ` function ` declaration.
11
+ ` data ` コンポーネントオプション宣言はプレーンな JavaScript ` object ` を受け入れず、 ` function ` 宣言を期待します。
12
12
13
- ## 2.x Syntax
13
+ ## 2.x での構文
14
14
15
- In 2.x, developers could define the ` data ` option with either an ` object ` or a ` function ` .
15
+ 2.x では、 ` data ` オプションは ` object ` か ` function ` のどちらか一方で定義できました。
16
16
17
- For example :
17
+ 例 :
18
18
19
19
``` html
20
- <!-- Object Declaration -->
20
+ <!-- オブジェクト宣言 -->
21
21
<script >
22
22
const app = new Vue ({
23
23
data: {
@@ -26,7 +26,7 @@ For example:
26
26
})
27
27
</script >
28
28
29
- <!-- Function Declaration -->
29
+ <!-- 関数宣言 -->
30
30
<script >
31
31
const app = new Vue ({
32
32
data () {
@@ -38,13 +38,13 @@ For example:
38
38
</script >
39
39
```
40
40
41
- Though this provided some convenience in terms of root instances having a shared state, this has led to confusion due to the fact that its only possible on the root instance.
41
+ これは状態が共有されているルートインスタンスに関してはある程度の利便性をもたらしましたが、ルートインスタンスでのみ可能であるという事実のため混乱を招きました。
42
42
43
- ## 3.x Update
43
+ ## 3.x での更新
44
44
45
- In 3.x, the ` data ` option has been standardized to only accept a ` function ` that returns an ` object ` .
45
+ 3.x では、 ` data ` オプションは ` object ` を返す ` function ` 宣言のみ受け入れるよう標準化されました。
46
46
47
- Using the example above, there would only be one possible implementation of the code :
47
+ 上記を例にすると、コードの可能な実装は1つだけです :
48
48
49
49
``` html
50
50
<script >
@@ -60,9 +60,9 @@ Using the example above, there would only be one possible implementation of the
60
60
</script >
61
61
```
62
62
63
- ## Migration Strategy
63
+ ## 移行の戦略
64
64
65
- For users relying on the object declaration, we recommend :
65
+ オブジェクト宣言を利用しているユーザーには以下を推奨します :
66
66
67
- - Extracting the shared data into an external object and using it as a property in ` data `
68
- - Rewrite references to the shared data to point to a new shared object
67
+ - 共有データを外部オブジェクトとして抽出し、それを ` data ` のプロパティとして使う
68
+ - 共有データへの参照、新しい共有オブジェクトを指すようにを書き換える
0 commit comments