Tab.js 766 Bytes
// components/Tab/Tab.js
import {componentsMixin } from '../../mixins/index'
Component({
  behaviors:[componentsMixin],
  /**
   * 组件的属性列表
   */
  properties: {
    tab: Array,
    openScroll: Boolean,
    index: {
      type: Number,
      observer: function (n) {
        this.setData({
          count: n,
          to: `to-${n}`
        })
      }
    },
    align: {
      type: String,
      default: ''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    count: 0,
    to: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    click(e) {
      let {
        count
      } = e.currentTarget.dataset
      this.setData({
        count,
        to: `to-${count}`
      })
      this.triggerEvent('click', count)
    }
  }
})