File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 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 : Props Default Function this Access
3
+ badges :
4
+ - breaking
5
+ ---
6
+
7
+ # Props Default Function ` this ` Access <MigrationBadges :badges =" $frontmatter.badges " />
8
+
9
+ Props default value factory functions no longer have access to ` this ` .
10
+
11
+ Instead:
12
+
13
+ - Raw props received by the component are passed to the default function as argument;
14
+
15
+ - The [ inject] ( ../composition-api-provide-inject.md ) API can be used inside default functions.
16
+
17
+ ``` js
18
+ import { inject } from ' vue'
19
+
20
+ export default {
21
+ props: {
22
+ theme: {
23
+ default (props ) {
24
+ // `props` is the raw values passed to the component,
25
+ // before any type / default coercions
26
+ // can also use `inject` to access injected properties
27
+ return inject (' theme' , ' default-theme' )
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ```
You can’t perform that action at this time.
0 commit comments