fix: form-model throw error when use v-model and change at the same time #1971
parent
2dcaf5d4ab
commit
1b60606832
|
@ -27,13 +27,15 @@ export default {
|
|||
__emit() {
|
||||
// 直接调用listeners,底层组件不需要vueTool记录events
|
||||
const args = [].slice.call(arguments, 0);
|
||||
const filterEvent = [];
|
||||
const eventName = args[0];
|
||||
if (args.length && this.$listeners[eventName]) {
|
||||
if (filterEvent.includes(eventName)) {
|
||||
this.$emit(eventName, ...args.slice(1));
|
||||
const event = this.$listeners[eventName];
|
||||
if (args.length && event) {
|
||||
if (Array.isArray(event)) {
|
||||
for (let i = 0, l = event.length; i < l; i++) {
|
||||
event[i](...args.slice(1));
|
||||
}
|
||||
} else {
|
||||
this.$listeners[eventName](...args.slice(1));
|
||||
event(...args.slice(1));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -232,14 +232,22 @@ export default {
|
|||
let firstChildren = children[0];
|
||||
if (this.prop && this.autoLink && isValidElement(firstChildren)) {
|
||||
const originalEvents = getEvents(firstChildren);
|
||||
const originalBlur = originalEvents.blur;
|
||||
const originalChange = originalEvents.change;
|
||||
firstChildren = cloneElement(firstChildren, {
|
||||
on: {
|
||||
blur: (...args) => {
|
||||
originalEvents.blur && originalEvents.blur(...args);
|
||||
originalBlur && originalBlur(...args);
|
||||
this.onFieldBlur();
|
||||
},
|
||||
change: (...args) => {
|
||||
originalEvents.change && originalEvents.change(...args);
|
||||
if (Array.isArray(originalChange)) {
|
||||
for (let i = 0, l = originalChange.length; i < l; i++) {
|
||||
originalChange[i](...args);
|
||||
}
|
||||
} else if (originalChange) {
|
||||
originalChange(...args);
|
||||
}
|
||||
this.onFieldChange();
|
||||
},
|
||||
},
|
||||
|
|
|
@ -211,4 +211,4 @@
|
|||
"lib/**/style/*",
|
||||
"*.less"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue