File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -976,7 +976,7 @@ type: api
976
976
977
977
- **Type:**
978
978
- **provide:** ` Object | () => Object `
979
- - **inject:** ` Array < string> | { [key: string]: string | Symbol }`
979
+ - **inject:** ` Array < string> | { [key: string]: string | Symbol | Object }`
980
980
981
981
- **Details:**
982
982
@@ -1055,6 +1055,42 @@ type: api
1055
1055
}
1056
1056
` ` `
1057
1057
1058
+ > In 2.5.0+ injections can be optional with default value:
1059
+
1060
+ ` ` ` js
1061
+ const Child = {
1062
+ inject: {
1063
+ foo: { default: ' foo' }
1064
+ }
1065
+ }
1066
+ ` ` `
1067
+
1068
+ If it needs to be injected from a property with a different name, use ` from` to denote the source property:
1069
+
1070
+ ` ` ` js
1071
+ const Child = {
1072
+ inject: {
1073
+ foo: {
1074
+ from: ' bar' ,
1075
+ default: ' foo'
1076
+ }
1077
+ }
1078
+ }
1079
+ ` ` `
1080
+
1081
+ Similar to prop defaults, you need to use a factory function for non primitive values:
1082
+
1083
+ ` ` ` js
1084
+ const Child = {
1085
+ inject: {
1086
+ foo: {
1087
+ from: ' bar' ,
1088
+ default : () => [1 , 2 , 3 ]
1089
+ }
1090
+ }
1091
+ }
1092
+ ` ` `
1093
+
1058
1094
## Options / Misc
1059
1095
1060
1096
### name
You can’t perform that action at this time.
0 commit comments