index.js 733 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const app = getApp()
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {},
  7. /**
  8. * 组件的初始数据
  9. */
  10. data: {
  11. active: 'pages/home/home',
  12. list: app.globalData.tabBarList
  13. },
  14. attached() {
  15. this.setData({
  16. list: app.globalData.tabBarList
  17. })
  18. app.addTabBarList = res => {
  19. this.setData({
  20. list: res
  21. })
  22. }
  23. },
  24. /**
  25. * 组件的方法列表
  26. */
  27. methods: {
  28. onChange(e) {
  29. const detail = e.detail
  30. wx.switchTab({
  31. url: `/${detail}`
  32. })
  33. this.setData({
  34. active: detail
  35. })
  36. },
  37. init() {
  38. const page = getCurrentPages().pop()
  39. this.setData({
  40. active: `${page.route}`
  41. })
  42. }
  43. }
  44. })