| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- // componets/custom-tab-bar/index.ts
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- active: 0,
- list: [{
- icon: 'home-o',
- text: '首页',
- url: '/pages/home/home/home'
- },
- {
- icon: 'search',
- text: '钻石圈',
- url: '/pages/circle/circle/circle'
- },
- {
- icon: 'search',
- text: '交易',
- url: '/pages/trade/trade/trade'
- },
- {
- icon: 'search',
- text: '我的',
- url: '/pages/mine/mine/mine'
- }]
- },
- /**
- * 组件的方法列表
- */
- methods: {
- onChange(e) {
- this.setData({ active: e.detail });
- console.log(this.data.list[e.detail].url)
- wx.switchTab({
- url: this.data.list[e.detail].url
- });
- },
-
- init() {
- const page = getCurrentPages().pop();
- this.setData({
- active: this.data.list.findIndex(item => item.url === `/${page.route}`)
- });
- }
- }
- })
|