index.js 911 B

1234567891011121314151617181920212223242526272829
  1. const app = getApp()
  2. Component({
  3. properties: {
  4. active: { type: Number, value: 0 },
  5. tabList: {
  6. type: Array, value: [
  7. { title: '报名中', active: 0 },
  8. { title: '未开始', active: 1 },
  9. { title: '进行中', active: 2 },
  10. { title: '已结束', active: 3 }
  11. ]
  12. },
  13. },
  14. data: {},
  15. methods: {
  16. //滑动切换
  17. swiperTab: function (e) {
  18. const that = this;
  19. that.triggerEvent('swiperTab', { active: e.detail.current })
  20. },
  21. //点击切换
  22. clickTab: function (e) {
  23. const that = this;
  24. if (that.data.active === e.target.dataset.active) return false
  25. else that.setData({ active: e.target.dataset.active })
  26. that.triggerEvent('clickTab', { active: e.target.dataset.active })
  27. },
  28. }
  29. })