From 7d325a262a8d9404cb782711b16ee4479bd817de Mon Sep 17 00:00:00 2001 From: lqq Date: Wed, 9 Oct 2019 14:44:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20segment=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/segment/index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/components/segment/index.js b/components/segment/index.js index b976c27..186d5a9 100644 --- a/components/segment/index.js +++ b/components/segment/index.js @@ -5,14 +5,24 @@ Component({ */ properties: { headerTitles: Array, - selectedTitle: Number + defaultSelectIndex: { + type: Number, + value: 0, + observer (newVal, oldVal) { + if (newVal != oldVal) { + this.setData({ + selectedTitle: newVal + }) + } + } + }, }, /** * 组件的初始数据 */ data: { - + selectedTitle: 0 }, /** @@ -21,6 +31,9 @@ Component({ methods: { bindtap: function (e) { const { item } = e.currentTarget.dataset + this.setData({ + selectedTitle: item + }) this.triggerEvent('tapSegment', item) }, }