index.ts 867 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // custom-tab-bar/index.ts
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. showBar: true, // 是否显示底部按钮
  13. selected: 0,
  14. color: "#AAAAAA",
  15. selectedColor: "#131415",
  16. list: [{
  17. pagePath: "/pages/index/index",
  18. iconPath: "./images/icon-home.png",
  19. selectedIconPath: "./images/icon-home-active.png",
  20. text: "首页"
  21. }, {
  22. pagePath: "/pages/orders/orders",
  23. iconPath: "./images/icon-order.png",
  24. selectedIconPath: "./images/icon-order-active.png",
  25. text: "订单"
  26. }]
  27. },
  28. /**
  29. * 组件的方法列表
  30. */
  31. methods: {
  32. switchTab(e: any) {
  33. const data = e.currentTarget.dataset
  34. const url = data.path
  35. wx.switchTab({ url })
  36. this.setData({
  37. selected: data.index
  38. })
  39. }
  40. }
  41. })