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() {
|
__emit() {
|
||||||
// 直接调用listeners,底层组件不需要vueTool记录events
|
// 直接调用listeners,底层组件不需要vueTool记录events
|
||||||
const args = [].slice.call(arguments, 0);
|
const args = [].slice.call(arguments, 0);
|
||||||
const filterEvent = [];
|
|
||||||
const eventName = args[0];
|
const eventName = args[0];
|
||||||
if (args.length && this.$listeners[eventName]) {
|
const event = this.$listeners[eventName];
|
||||||
if (filterEvent.includes(eventName)) {
|
if (args.length && event) {
|
||||||
this.$emit(eventName, ...args.slice(1));
|
if (Array.isArray(event)) {
|
||||||
|
for (let i = 0, l = event.length; i < l; i++) {
|
||||||
|
event[i](...args.slice(1));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$listeners[eventName](...args.slice(1));
|
event(...args.slice(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -232,14 +232,22 @@ export default {
|
||||||
let firstChildren = children[0];
|
let firstChildren = children[0];
|
||||||
if (this.prop && this.autoLink && isValidElement(firstChildren)) {
|
if (this.prop && this.autoLink && isValidElement(firstChildren)) {
|
||||||
const originalEvents = getEvents(firstChildren);
|
const originalEvents = getEvents(firstChildren);
|
||||||
|
const originalBlur = originalEvents.blur;
|
||||||
|
const originalChange = originalEvents.change;
|
||||||
firstChildren = cloneElement(firstChildren, {
|
firstChildren = cloneElement(firstChildren, {
|
||||||
on: {
|
on: {
|
||||||
blur: (...args) => {
|
blur: (...args) => {
|
||||||
originalEvents.blur && originalEvents.blur(...args);
|
originalBlur && originalBlur(...args);
|
||||||
this.onFieldBlur();
|
this.onFieldBlur();
|
||||||
},
|
},
|
||||||
change: (...args) => {
|
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();
|
this.onFieldChange();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -211,4 +211,4 @@
|
||||||
"lib/**/style/*",
|
"lib/**/style/*",
|
||||||
"*.less"
|
"*.less"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue