From 19cd2ed38e2ae72e48ae759b843a33808eee5e16 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 9 Aug 2019 11:54:42 +0800 Subject: [PATCH] [improvement] optimize watch options (#4075) --- src/area/index.js | 4 +--- src/count-down/demo/index.vue | 11 ++--------- src/count-down/index.js | 4 +--- src/coupon-list/index.js | 4 +--- src/mixins/popup/index.js | 4 +--- src/mixins/portal.ts | 4 +--- src/picker/index.js | 4 +--- src/progress/index.js | 13 ++++--------- src/sku/Sku.js | 4 +--- src/tabbar/index.js | 9 ++------- src/tabs/index.js | 6 ++---- src/toast/Toast.js | 9 ++------- 12 files changed, 19 insertions(+), 57 deletions(-) diff --git a/src/area/index.js b/src/area/index.js index 05423c6e4..7bf965c56 100644 --- a/src/area/index.js +++ b/src/area/index.js @@ -51,9 +51,7 @@ export default createComponent({ areaList: { deep: true, - handler() { - this.setValues(); - } + handler: 'setValues' }, columnsNum() { diff --git a/src/count-down/demo/index.vue b/src/count-down/demo/index.vue index 860a45f1c..a1e6417fc 100644 --- a/src/count-down/demo/index.vue +++ b/src/count-down/demo/index.vue @@ -35,7 +35,7 @@ { this.progressWidth = this.$el.offsetWidth; this.pivotWidth = this.$refs.pivot ? this.$refs.pivot.offsetWidth : 0; diff --git a/src/sku/Sku.js b/src/sku/Sku.js index f262b5fef..99ed73c98 100644 --- a/src/sku/Sku.js +++ b/src/sku/Sku.js @@ -105,9 +105,7 @@ export default createComponent({ this.show = val; }, - skuTree(val) { - this.resetSelectedSku(val); - } + skuTree: 'resetSelectedSku' }, computed: { diff --git a/src/tabbar/index.js b/src/tabbar/index.js index 2cc8a8da2..c2c8d310a 100644 --- a/src/tabbar/index.js +++ b/src/tabbar/index.js @@ -30,13 +30,8 @@ export default createComponent({ }, watch: { - children() { - this.setActiveItem(); - }, - - value() { - this.setActiveItem(); - } + value: 'setActiveItem', + children: 'setActiveItem' }, methods: { diff --git a/src/tabs/index.js b/src/tabs/index.js index 69403d739..d743db973 100644 --- a/src/tabs/index.js +++ b/src/tabs/index.js @@ -99,16 +99,14 @@ export default createComponent({ }, watch: { + color: 'setLine', + active(name) { if (name !== this.currentName) { this.setCurrentIndexByName(name); } }, - color() { - this.setLine(); - }, - children() { this.setCurrentIndexByName(this.currentName || this.active); this.scrollIntoView(); diff --git a/src/toast/Toast.js b/src/toast/Toast.js index a7d4c1105..cfd3b611d 100644 --- a/src/toast/Toast.js +++ b/src/toast/Toast.js @@ -44,13 +44,8 @@ export default createComponent({ }, watch: { - value() { - this.toggleClickable(); - }, - - forbidClick() { - this.toggleClickable(); - } + value: 'toggleClickable', + forbidClick: 'toggleClickable' }, methods: {