Commit 4b20374b authored by baiyaaaaa's avatar baiyaaaaa Committed by 杨奕

support use checkbox without transport value

parent 217bb5c9
...@@ -49,17 +49,27 @@ ...@@ -49,17 +49,27 @@
componentName: 'ElCheckbox', componentName: 'ElCheckbox',
data() {
return {
selfModel: false
};
},
computed: { computed: {
model: { model: {
get() { get() {
return this.isGroup ? this.store : this.value; return this.isGroup
? this.store : this.value !== undefined
? this.value : this.selfModel;
}, },
set(val) { set(val) {
if (this.isGroup) { if (this.isGroup) {
this.dispatch('ElCheckboxGroup', 'input', [val]); this.dispatch('ElCheckboxGroup', 'input', [val]);
} else { } else if (this.value !== undefined) {
this.$emit('input', val); this.$emit('input', val);
} else {
this.selfModel = val;
} }
} }
}, },
...@@ -105,8 +115,11 @@ ...@@ -105,8 +115,11 @@
methods: { methods: {
addToStore() { addToStore() {
if (Array.isArray(this.model)) { if (
this.model.indexOf(this.label) === -1 && this.model.push(this.label); Array.isArray(this.model) &&
this.model.indexOf(this.label) === -1
) {
this.model.push(this.label);
} else { } else {
this.model = this.trueLabel || true; this.model = this.trueLabel || true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment