闫增涛
2024-03-21 b273028fde3178d2643312c66d943b12f2c1bfad
custom-tab-bar/index.js
@@ -4,14 +4,20 @@
    active: 0,
    list: TabMenu,
  },
  observers: {
    'active': function (newValue) {
      console.log('active变化', newValue);
    }
  },
  methods: {
    onChange(event) {
      this.setData({ active: event.detail.value });
      console.log(event);
      this.setData({ active: this.data.list[event.detail.value].id });
      const url = this.data.list[event.detail.value].url.startsWith('/')
        ? this.data.list[event.detail.value].url
        : `/${this.data.list[event.detail.value].url}`
      wx.switchTab({
        url: this.data.list[event.detail.value].url.startsWith('/')
          ? this.data.list[event.detail.value].url
          : `/${this.data.list[event.detail.value].url}`,
        url: url
      });
    },