index.js 712 Bytes

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    contentArray: {
      type: Array,
      value: [],
    },
    select: {
      type: Number,
      observer(newVal, oldVal) {
        this.setData({
          selectIndex: newVal,
          toView: `tab-${newVal - 1}`
        })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    selectIndex: 0,
    toView: 'tab-0'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    tapSilderItem(e) {

      let data = e.currentTarget.dataset;
      this.setData({
        selectIndex: data.index,
        toView: `tab-${data.index - 1}`
      })
      this.triggerEvent('selectTab', { index: data.index } );
    }
  }
})