Tab.js 1.24 KB
/*
 * @Description: 
 * @Author: huyue
 * @Date: 2022-12-09 14:13:50
 * @LastEditors: huyue
 * @LastEditTime: 2023-01-11 15:14:15
 */
// components/Tab/Tab.js
//  behaviors: [LocationBehavior],
// import { imgUrlMixin } from '~/mixins/index'

Component({
  // behaviors: [imgUrlMixin],
  options: {
    addGlobalClass: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    outClassName:String,
    tab: Array,
    openScroll: Boolean,
    tabHeight: {
      type: Boolean,
      value: false
    },
    productHeight: {
      type: Boolean,
      value: false
    },
    index: {
      type: Number,
      observer: function (n) {
        this.setData({
          count: n,
          to: `to-${n}`
        })
      }
    },
    itemWidth: String,
    align: {
      type: String,
      value: ''
    },
    // 是否有红点
    unreadClueCount:  {
      type: Number,
      value: 0
    },
  },

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

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