From 8a27f5724e10e82cc5a30bf7051397da2e697e63 Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期四, 19 十二月 2024 10:49:11 +0800 Subject: [PATCH] bug优化,答题卡初始化 --- custom-tab-bar/index.js | 29 +++++------------------------ 1 files changed, 5 insertions(+), 24 deletions(-) diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index a38dc4a..edef97d 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -1,34 +1,15 @@ import TabMenu from './data'; Component({ data: { - selected: 0, + active: 0, list: TabMenu, }, - // observers: { - // 'active': function (newValue) { - // console.log('active鍙樺寲', newValue); - // } - // }, methods: { changeTab(item) { - this.setData({ - selected: item.currentTarget.dataset.num - }) wx.switchTab({ - url: this.data.list[this.data.selected].url.startsWith('/') ? - this.data.list[this.data.selected].url : `/${this.data.list[this.data.selected].url}`, + url: this.data.list[item.currentTarget.dataset.num].url.startsWith('/') ? + this.data.list[item.currentTarget.dataset.num].url : `/${this.data.list[item.currentTarget.dataset.num].url}`, }); - }, - - // init() { - // const page = getCurrentPages().pop(); - // const route = page ? page.route.split('?')[0] : ''; - // const active = this.data.list.findIndex( - // (item) => - // (item.url.startsWith('/') ? item.url.substr(1) : item.url) === - // `${route}`, - // ); - // this.setData({ active }); - // }, + } }, -}); +}); \ No newline at end of file -- Gitblit v1.9.1