// components/tab/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    tab: Object
  },

  /**
   * 组件的初始数据
   */
  data: {
    cur_index: 0,
    reloads: []
  },
  ready() {
    this.data.reloads = this.data.tab.items.map(x => ({}))
  },
  methods: {
    meunTap({
      currentTarget: {
        dataset: {
          index: cur_index
        }
      }
    }) {
      this.setData({
        cur_index
      })
    },
    swiperChange: function ({
      detail: {
        current: cur_index
      }
    }) {
      this.setData({
        cur_index
      })
    },
    change({ currentTarget: { dataset: { index } } }) {
      let reloads = {};
      this.data.reloads.forEach((x, i) => {
        if (i === index) return
        reloads[`reloads[${i}]`] = {}
      })
      this.setData(reloads)
    }
  }
})