1234567891011121314151617181920212223242526272829 |
- Component({
- data: {
- value: 0,
- tabBar: [{
- url: '/pages/index/index',
- icon: 'home',
- label: '首页',
- }, {
- url: '/pages/my/my',
- icon: 'user',
- label: '我的'
- }]
- },
- methods: {
- onChange(e: WechatMiniprogram.TouchEvent) {
- this.setData({ value: e.detail.value });
- wx.switchTab({
- url: this.data.tabBar[e.detail.value].url
- });
- },
- init() {
- const page = getCurrentPages().pop();
- this.setData({
- value: this.data.tabBar.findIndex(item => item.url === `/${page?.route}`)
- });
- }
- },
- })
|