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