fixed #1399
This commit is contained in:
parent
a3f7e0d25e
commit
6c97e57a80
3 changed files with 410 additions and 131 deletions
|
@ -17,7 +17,15 @@
|
|||
mixins: [ Emitter ],
|
||||
props: {
|
||||
value: {
|
||||
type: Boolean,
|
||||
type: [String, Number, Boolean],
|
||||
default: false
|
||||
},
|
||||
trueValue: {
|
||||
type: [String, Number, Boolean],
|
||||
default: true
|
||||
},
|
||||
falseValue: {
|
||||
type: [String, Number, Boolean],
|
||||
default: false
|
||||
},
|
||||
disabled: {
|
||||
|
@ -56,7 +64,8 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
const checked = !this.currentValue;
|
||||
const checked = this.currentValue === this.trueValue ? this.falseValue : this.trueValue;
|
||||
|
||||
this.currentValue = checked;
|
||||
this.$emit('input', checked);
|
||||
this.$emit('on-change', checked);
|
||||
|
@ -65,6 +74,9 @@
|
|||
},
|
||||
watch: {
|
||||
value (val) {
|
||||
if (val !== this.trueValue && val !== this.falseValue) {
|
||||
throw 'Value should be trueValue or falseValue.';
|
||||
}
|
||||
this.currentValue = val;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue