index.ts 587 B

123456789101112131415161718192021222324252627282930313233343536
  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. this.setData({
  27. pageName: url
  28. }, () => {
  29. console.log(this.data.pageName)
  30. app.globalData.tabActive = url;
  31. wx.switchTab({ url })
  32. })
  33. }
  34. }
  35. })