From 236bcd69fcb3405935882d765b3d714616d1e2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=87=91=E5=B9=B3?= <32758131+NameWjp@users.noreply.github.com> Date: Tue, 20 Apr 2021 17:42:54 +0800 Subject: [PATCH] fixbug #3232 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 监听父组件的变化后不需要再 $emit --- packages/datetime-picker/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/datetime-picker/index.ts b/packages/datetime-picker/index.ts index 804dde1d3..dba469234 100644 --- a/packages/datetime-picker/index.ts +++ b/packages/datetime-picker/index.ts @@ -52,7 +52,7 @@ VantComponent({ ...pickerProps, value: { type: null, - observer: 'updateValue', + observer: 'updateValueNotEmit', }, filter: null, type: { @@ -118,6 +118,17 @@ VantComponent({ this.updateColumns(); } }, + + updateValueNotEmit() { + const { data } = this; + const val = this.correctValue(data.value); + const isEqual = val === data.innerValue; + if (!isEqual) { + this.updateColumnValue(val); + } else { + this.updateColumns(); + } + }, getPicker() { if (this.picker == null) {