File tree Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<p class =" demo" >
3
- <button class =" btn" :style =" { color: '#fff', backgroundColor: primary && theme.primaryColor }" >
3
+ <button class =" btn" :style =" { color: '#fff', backgroundColor: ( primary && theme.primaryColor) || (secondary && theme.secondaryColor) }" >
4
4
<slot ></slot >
5
5
</button >
6
6
</p >
10
10
export default {
11
11
inject: {
12
12
theme: {
13
- default: {
14
- primaryColor: ' darkseagreen' ,
15
- },
13
+ default: {},
16
14
},
17
15
},
18
16
props: {
19
17
primary: {
20
18
type: Boolean ,
21
- default: true ,
19
+ default: false ,
20
+ },
21
+ secondary: {
22
+ type: Boolean ,
23
+ default: false ,
22
24
},
23
25
},
24
26
};
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ export default {
3
3
provide: {
4
4
theme: {
5
5
primaryColor: ' #3eaf7c' ,
6
+ secondaryColor: ' #1FA2FF'
6
7
},
7
8
},
8
9
render (h ) {
Original file line number Diff line number Diff line change @@ -878,8 +878,12 @@ export default {
878
878
provide: {
879
879
theme: {
880
880
primaryColor: ' #3eaf7c' ,
881
+ secondaryColor: ' #1FA2FF'
881
882
},
882
883
},
884
+ render (h ) {
885
+ return this .$slots .default [0 ];
886
+ },
883
887
};
884
888
```
885
889
@@ -888,7 +892,7 @@ export default {
888
892
889
893
<template>
890
894
<p class="demo">
891
- <button class="btn" :style="{ color: '#fff', backgroundColor: primary && theme.primaryColor }">
895
+ <button class="btn" :style="{ color: '#fff', backgroundColor: ( primary && theme.primaryColor) || (secondary && theme.secondaryColor) }">
892
896
<slot></slot>
893
897
</button>
894
898
</p>
@@ -898,15 +902,17 @@ export default {
898
902
export default {
899
903
inject: {
900
904
theme: {
901
- default: {
902
- primaryColor: 'darkseagreen',
903
- },
905
+ default: {},
904
906
},
905
907
},
906
908
props: {
907
909
primary: {
908
910
type: Boolean,
909
- default: true,
911
+ default: false,
912
+ },
913
+ secondary: {
914
+ type: Boolean,
915
+ default: false,
910
916
},
911
917
},
912
918
};
@@ -915,14 +921,14 @@ export default {
915
921
916
922
``` vue
917
923
<theme-provider>
918
- <theme-button>Themed Button</theme-button>
924
+ <theme-button secondary >Themed Button</theme-button>
919
925
</theme-provider>
920
926
```
921
927
922
928
#### Working Example:
923
929
924
930
<ThemeProvider >
925
- <ThemeButton >Themed Button</ThemeButton >
931
+ <ThemeButton secondary >Themed Button</ThemeButton >
926
932
</ThemeProvider >
927
933
928
934
### [ @Provide / @Inject Decorator] ( https://github.com/kaorun343/vue-property-decorator )
You can’t perform that action at this time.
0 commit comments