From c6ba8815fbaf91c6764ebd842eaf108b04aa6938 Mon Sep 17 00:00:00 2001 From: iczer <1126263215@qq.com> Date: Thu, 2 Jul 2020 21:53:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20selection=20problem=20in=20ColorCheckBox?= =?UTF-8?q?=20radio=20mode;=20:bug:=20=E4=BF=AE=E5=A4=8D=EF=BC=9AColorChec?= =?UTF-8?q?kBox=20=E5=8D=95=E9=80=89=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/checkbox/ColorCheckbox.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/checkbox/ColorCheckbox.vue b/src/components/checkbox/ColorCheckbox.vue index 90efa10..b90e55e 100644 --- a/src/components/checkbox/ColorCheckbox.vue +++ b/src/components/checkbox/ColorCheckbox.vue @@ -42,8 +42,8 @@ const Group = { } }, watch: { - values() { - this.$emit('change', this.values, this.colors) + values(value) { + this.$emit('change', value, this.colors) }, defaultValues(value) { if (this.multiple) { @@ -61,9 +61,12 @@ const Group = { methods: { handleChange (option) { if (!option.checked) { - this.values = this.values.filter(item => item !== option.value) + if (this.values.indexOf(option.value) > -1) { + this.values = this.values.filter(item => item != option.value) + } } else { if (!this.multiple) { + this.values = [option.value] this.options.forEach(item => { if (item.value != option.value) { item.sChecked = false @@ -133,7 +136,9 @@ export default { }, methods: { toggle () { - this.sChecked = !this.sChecked + if (this.groupContext.multiple || !this.sChecked) { + this.sChecked = !this.sChecked + } }, initChecked() { let groupContext = this.groupContext