mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
fix #1625 pull request 改动点: - 重构组件,优化性能 - 新增 inactiveColor、name 属性 - 完善文档,增加小程序自定义tab-bar示例
34 lines
623 B
JavaScript
34 lines
623 B
JavaScript
Component({
|
|
data: {
|
|
active: 0,
|
|
list: [
|
|
{
|
|
icon: 'home-o',
|
|
text: 'tabbar示例1',
|
|
url: '/pages/tabbar/index'
|
|
},
|
|
{
|
|
icon: 'search',
|
|
text: 'tabbar示例2',
|
|
url: '/pages/tabbar1/index'
|
|
}
|
|
]
|
|
},
|
|
|
|
methods: {
|
|
onChange(event) {
|
|
this.setData({ active: event.detail });
|
|
wx.switchTab({
|
|
url: this.data.list[event.detail].url
|
|
});
|
|
},
|
|
|
|
init() {
|
|
const page = getCurrentPages().pop();
|
|
this.setData({
|
|
active: this.data.list.findIndex(item => item.url === `/${page.route}`)
|
|
});
|
|
}
|
|
}
|
|
});
|