Open WangZhenHao opened 3 years ago
浏览器版本/ vue-2.6.5
https://jsfiddle.net/w0afLenb/
改变v-model的值的时候
触发on-change事件
没有触发on-change事件
目前可以重写一下Select组件的watch的values方法
ViewUI.Select.watch.values = function(now, before){ const newValue = JSON.stringify(now); const oldValue = JSON.stringify(before); // 改变 labelInValue 的实现:直接在 emit 时改数据 const vModelValue = this.publicValue; const shouldEmitInput = newValue !== oldValue && vModelValue !== this.value; if (shouldEmitInput) { let emitValue = this.publicValue; if (this.labelInValue) { if (this.multiple) { emitValue = this.values; } else { emitValue = this.values[0]; } } this.$emit('input', vModelValue); // to update v-model this.$emit('on-change', emitValue); this.dispatch('FormItem', 'on-form-change', emitValue); } else if(!this.multiple) { const bNow = now[0] || {} const bValue = before[0] || {}; if(bNow.value !== bValue.value) { this.$emit('on-change', this.publicValue); } } }
Environment
浏览器版本/ vue-2.6.5
Reproduction link
https://jsfiddle.net/w0afLenb/
Steps to reproduce
改变v-model的值的时候
What is expected?
触发on-change事件
What is actually happening?
没有触发on-change事件
目前可以重写一下Select组件的watch的values方法