index.ts 969 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // componets/custom-tab-bar/index.ts
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. active: 0,
  13. list: [{
  14. icon: 'home-o',
  15. text: '首页',
  16. url: '/pages/home/home/home'
  17. },
  18. {
  19. icon: 'search',
  20. text: '钻石圈',
  21. url: '/pages/circle/circle/circle'
  22. },
  23. {
  24. icon: 'search',
  25. text: '交易',
  26. url: '/pages/trade/trade/trade'
  27. },
  28. {
  29. icon: 'search',
  30. text: '我的',
  31. url: '/pages/mine/mine/mine'
  32. }]
  33. },
  34. /**
  35. * 组件的方法列表
  36. */
  37. methods: {
  38. onChange(e) {
  39. this.setData({ active: e.detail });
  40. console.log(this.data.list[e.detail].url)
  41. wx.switchTab({
  42. url: this.data.list[e.detail].url
  43. });
  44. },
  45. init() {
  46. const page = getCurrentPages().pop();
  47. this.setData({
  48. active: this.data.list.findIndex(item => item.url === `/${page.route}`)
  49. });
  50. }
  51. }
  52. })