This commit is contained in:
2025-12-05 15:41:32 +08:00
commit 7339c71fc0
1433 changed files with 37574 additions and 0 deletions

50
custom-tab-bar/index.js Normal file
View File

@@ -0,0 +1,50 @@
Component({
options: {
addGlobalClass: true
},
data: {
active: 0,
list: [
{
pagePath: '/pages/index/index',
text: '首页',
icon: 'home-o',
activeIcon: 'wap-home'
},
{
pagePath: '/pages/category/category',
text: '分类',
icon: 'apps-o',
activeIcon: 'apps-o'
},
{
pagePath: '/pages/mine/mine',
text: '我的',
icon: 'user-o',
activeIcon: 'manager'
}
]
},
methods: {
onChange(e) {
const index = e.detail;
const item = this.data.list[index];
wx.switchTab({
url: item.pagePath
});
},
init() {
const page = getCurrentPages().pop();
const route = page ? `/${page.route}` : '';
const active = this.data.list.findIndex(item => item.pagePath === route);
if (active !== -1) {
this.setData({ active });
}
}
}
});