From 90c3d221cb75230b5edd77c54fbd679a0759e326 Mon Sep 17 00:00:00 2001 From: ajuner <106791576@qq.com> Date: Fri, 26 Feb 2021 13:33:27 +0800 Subject: [PATCH] fix: update data before callback --- components/calendar/index.tsx | 2 +- components/input/Search.tsx | 2 +- components/vc-pagination/Pagination.jsx | 2 +- components/vc-switch/Switch.jsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index 65081d452e..13750aaed4 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -93,11 +93,11 @@ const Calendar = defineComponent({ }, triggerPanelChange(value: moment.Moment, mode: CalendarMode | undefined) { const val = this.valueFormat ? momentToString(value, this.valueFormat) : value; - this.$emit('panelChange', val, mode); if (value !== this.sValue) { this.$emit('update:value', val); this.$emit('change', val); } + this.$emit('panelChange', val, mode); }, triggerSelect(value: moment.Moment) { diff --git a/components/input/Search.tsx b/components/input/Search.tsx index 357298384f..bbc2ddad2c 100644 --- a/components/input/Search.tsx +++ b/components/input/Search.tsx @@ -32,10 +32,10 @@ export default defineComponent({ this.input = node; }, handleChange(e: Event) { + this.$emit('update:value', (e.target as HTMLInputElement).value); if (e && e.target && e.type === 'click') { this.$emit('search', (e.target as HTMLInputElement).value, e); } - this.$emit('update:value', (e.target as HTMLInputElement).value); this.$emit('change', e); }, handleSearch(e: Event) { diff --git a/components/vc-pagination/Pagination.jsx b/components/vc-pagination/Pagination.jsx index 85b2af5676..7890e44a55 100644 --- a/components/vc-pagination/Pagination.jsx +++ b/components/vc-pagination/Pagination.jsx @@ -237,10 +237,10 @@ export default defineComponent({ } } this.__emit('update:pageSize', size); - this.__emit('showSizeChange', current, size); if (current !== preCurrent) { this.__emit('update:current', current); } + this.__emit('showSizeChange', current, size); }, handleChange(p) { const { disabled } = this.$props; diff --git a/components/vc-switch/Switch.jsx b/components/vc-switch/Switch.jsx index b1256c9de6..c3ac8a6f48 100644 --- a/components/vc-switch/Switch.jsx +++ b/components/vc-switch/Switch.jsx @@ -51,8 +51,8 @@ export default defineComponent({ if (!hasProp(this, 'checked')) { this.stateChecked = checked; } - this.__emit('change', checked, e); this.__emit('update:checked', checked); + this.__emit('change', checked, e); }, handleClick(e) { const checked = !this.stateChecked;