index.ts 530 B

1234567891011121314151617181920212223242526272829303132
  1. // custom-tab-bar/index.ts
  2. const app = getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. },
  9. ready() {
  10. this.setData({
  11. pageName: app.globalData.tabActive
  12. })
  13. },
  14. /**
  15. * 组件的初始数据
  16. */
  17. data: {
  18. pageName: ""
  19. },
  20. /**
  21. * 组件的方法列表
  22. */
  23. methods: {
  24. changepage(e: any) {
  25. const url = e.target.dataset.index;
  26. if(app.globalData.tabActive === url) return
  27. app.globalData.tabActive = url;
  28. wx.switchTab({ url })
  29. }
  30. }
  31. })