|  1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 | Component({
  data: {
    selected: 0,
    color: "#ffffff",
    selectedColor: "#c97587",
    "list": [
      {
        "pagePath": "/pages/index/index",
        "text": "❤️",
        "iconPath": "",
        "selectedIconPath": ""
      },
      {
        "pagePath": "/pages/message/message",
        "text": "💌",
        "iconPath": "",
        "selectedIconPath": ""
      },
      {
        "pagePath": "/pages/goal/goal",
        "text": "📝",
        "iconPath": "",
        "selectedIconPath": ""
      },
    ],
  },
  attached() {
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      //切换tab时,改变路由地址
      wx.switchTab({url})
      this.setData({
        //切换tab时,改变当前激活的序号,改变tab颜色图标等样式  
        selected: data.index
      })
    }
  }
})
 |