From c895bf173974c6503a7483a60d5dbe5c620675e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Sat, 18 Jan 2020 10:58:12 +0800 Subject: [PATCH] chore: improve watcher --- src/area/index.js | 4 ++-- src/calendar/index.js | 4 +--- src/circle/index.js | 4 ++-- src/number-keyboard/index.js | 4 ++-- src/picker/PickerColumn.js | 4 ++-- src/stepper/index.js | 10 +++++----- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/area/index.js b/src/area/index.js index b2d1940dd..4d4bc3aaa 100644 --- a/src/area/index.js +++ b/src/area/index.js @@ -66,8 +66,8 @@ export default createComponent({ }, watch: { - value() { - this.code = this.value; + value(val) { + this.code = val; this.setValues(); }, diff --git a/src/calendar/index.js b/src/calendar/index.js index c0bc0b3cc..300a2a6c2 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -118,9 +118,7 @@ export default createComponent({ }, watch: { - type() { - this.reset(); - }, + type: 'reset', value(val) { if (val) { diff --git a/src/circle/index.js b/src/circle/index.js index 2c1d2adfa..0931229fb 100644 --- a/src/circle/index.js +++ b/src/circle/index.js @@ -127,10 +127,10 @@ export default createComponent({ watch: { rate: { - handler() { + handler(rate) { this.startTime = Date.now(); this.startRate = this.value; - this.endRate = format(this.rate); + this.endRate = format(rate); this.increase = this.endRate > this.startRate; this.duration = Math.abs( ((this.startRate - this.endRate) * 1000) / this.speed diff --git a/src/number-keyboard/index.js b/src/number-keyboard/index.js index 408d5fe69..af7fac9dc 100644 --- a/src/number-keyboard/index.js +++ b/src/number-keyboard/index.js @@ -65,9 +65,9 @@ export default createComponent({ }, watch: { - show() { + show(val) { if (!this.transition) { - this.$emit(this.show ? 'show' : 'hide'); + this.$emit(val ? 'show' : 'hide'); } } }, diff --git a/src/picker/PickerColumn.js b/src/picker/PickerColumn.js index 5fb46245f..66fa47945 100644 --- a/src/picker/PickerColumn.js +++ b/src/picker/PickerColumn.js @@ -73,8 +73,8 @@ export default createComponent({ }, watch: { - defaultIndex() { - this.setIndex(this.defaultIndex); + defaultIndex(val) { + this.setIndex(val); } }, diff --git a/src/stepper/index.js b/src/stepper/index.js index 75de4ecca..6ccfdb679 100644 --- a/src/stepper/index.js +++ b/src/stepper/index.js @@ -112,17 +112,17 @@ export default createComponent({ }, watch: { + max: 'check', + min: 'check', + integer: 'check', + decimalLength: 'check', + value(val) { if (!equal(val, this.currentValue)) { this.currentValue = this.format(val); } }, - max: 'check', - min: 'check', - integer: 'check', - decimalLength: 'check', - currentValue(val) { this.$emit('input', val); this.$emit('change', val, { name: this.name });