cate-one.vue 835 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <view class="cate-one">
  3. <tabs @change="changeActive" v-if="cateList.length">
  4. <tab :name="item.name" v-for="(item, index) in cateList" :key="index">
  5. <cate-list v-if="showCate[index]" :top="174" ref="mescrollItem" :i="index" :index="selectIndex" :cate="item">
  6. </cate-list>
  7. </tab>
  8. </tabs>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. name:"cate-one",
  14. props: {
  15. cateList: {
  16. type: Array,
  17. default: () => ([])
  18. },
  19. },
  20. data() {
  21. return {
  22. selectIndex: 0,
  23. showCate: []
  24. };
  25. },
  26. methods:{
  27. changeActive(index) {
  28. this.selectIndex = index
  29. this.showCate[index] = true
  30. },
  31. },
  32. watch: {
  33. cateList(val) {
  34. this.showCate = val.map((item, index) => index == this.selectIndex ? true : false)
  35. console.log(this.showCate)
  36. }
  37. }
  38. }
  39. </script>
  40. <style>
  41. </style>