未验证 提交 433b882c 编写于 作者: Q QiuShuiBai 提交者: GitHub

fix(checkboxgroup): fix a bug when checkboxgroup set the min props (#705)

set the min props in checkboxgroup. And checkboxgroup will add value in checkList when repeatedly
click the selected checkbox
上级 5a8f3cfa
......@@ -81,14 +81,14 @@
},
mounted () {
this.$on(EVENT_CHECKED, (value) => {
if (this._value.length < this.max) {
if (this._value.length < this.max && this._value.indexOf(value) === -1) {
this._value.push(value)
}
this.$emit(EVENT_INPUT, this._value)
})
this.$on(EVENT_CANCLE_CHECKED, (value) => {
if (this._value.length > this.min) {
const index = this._value.indexOf(value)
const index = this._value.indexOf(value)
if (this._value.length > this.min && index > -1) {
this._value.splice(index, 1)
}
this.$emit(EVENT_INPUT, this._value)
......
......@@ -92,9 +92,11 @@
set (newValue) {
const value = this.computedOption.value
const emitValue = value && newValue ? value : newValue
const parentEmitEvent = newValue ? EVENT_CHECKED : EVENT_CANCLE_CHECKED
this.$emit(EVENT_INPUT, emitValue)
if (this.isInGroup) {
// fix a bug when checkboxgroup set the min props
newValue = !this.checkValue
const parentEmitEvent = newValue ? EVENT_CHECKED : EVENT_CANCLE_CHECKED
this.$parent.$emit(parentEmitEvent, value || newValue)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册