File tree 2 files changed +33
-0
lines changed 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ const sidebar = {
125
125
'migration/global-api-treeshaking' ,
126
126
'migration/inline-template-attribute' ,
127
127
'migration/keycode-modifiers' ,
128
+ 'migration/props-default-this' ,
128
129
'migration/render-function-api' ,
129
130
'migration/slots-unification' ,
130
131
'migration/transition' ,
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : プロパティのデフォルト値ファクトリ関数の `this` アクセス
3
+ badges :
4
+ - breaking
5
+ ---
6
+
7
+ # プロパティのデフォルト値ファクトリ関数の ` this ` アクセス <MigrationBadges :badges =" $frontmatter.badges " />
8
+
9
+ プロパティのデフォルト値ファクトリ関数が ` this ` にアクセスできなくなりました。
10
+
11
+ 代わりの方法は以下です。
12
+
13
+ - コンポーネントが受け取った生のプロパティは、引数としてデフォルト関数に渡されます。
14
+
15
+ - [ inject] ( ../composition-api-provide-inject.md ) API がデフォルト関数の内部で使用できます。
16
+
17
+ ``` js
18
+ import { inject } from ' vue'
19
+
20
+ export default {
21
+ props: {
22
+ theme: {
23
+ default (props ) {
24
+ // `props` 引数はコンポーネントに渡される生の値で、
25
+ // 型やデフォルトの強制より前のものです。
26
+ // また、`inject` を使用して注入されたプロパティにアクセスすることもできます。
27
+ return inject (' theme' , ' default-theme' )
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ```
You can’t perform that action at this time.
0 commit comments