1234567891011121314151617181920212223242526272829303132333435363738 |
- Component({
- data: {
- active: 0,
- list: [
- {
- icon: 'home-o',
- text: '首页',
- url: '/pages/index/index'
- },
- {
- icon: 'bar-chart-o',
- text: '数据中心',
- url: '/pages/data/index'
- },
- {
- icon: 'user-o',
- text: '个人中心',
- url: '/pages/account/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}`)
- });
- }
- }
- });
|