Switch add new prop: true-color & false-color

This commit is contained in:
梁灏 2019-09-05 14:13:31 +08:00
parent e3930b7ace
commit 485db11ee2
2 changed files with 24 additions and 1 deletions

View file

@ -2,6 +2,7 @@
<span
tabindex="0"
:class="wrapClasses"
:style="wrapStyles"
@click="toggle"
@keydown.space="toggle"
>
@ -52,6 +53,12 @@
loading: {
type: Boolean,
default: false
},
trueColor: {
type: String
},
falseColor: {
type: String
}
},
data () {
@ -71,6 +78,19 @@
}
];
},
wrapStyles () {
let style = {};
if (this.trueColor && this.currentValue === this.trueValue) {
style['border-color'] = this.trueColor;
style['background-color'] = this.trueColor;
} else if (this.falseColor && this.currentValue === this.falseValue) {
style['border-color'] = this.falseColor;
style['background-color'] = this.falseColor;
}
return style;
},
innerClasses () {
return `${prefixCls}-inner`;
}