综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mescroll-swiper.vue 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view>
  3. <!-- 当设置tab-width,指定每个tab宽度时,则不使用flex布局,改用水平滑动 -->
  4. <me-tabs v-model="tabIndex" :tabs="tabs" :fixed="true" :tab-width="130"></me-tabs>
  5. <swiper :style="{height: height}" :current="tabIndex" @change="swiperChange">
  6. <swiper-item v-for="(tab,i) in tabs" :key="i">
  7. <mescroll-item ref="mescrollItem" :i="i" :index="tabIndex" :tabs="tabs"></mescroll-item>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. </template>
  12. <script>
  13. import MescrollItem from "./mescroll-swiper-item.vue";
  14. export default {
  15. components: {
  16. MescrollItem
  17. },
  18. data() {
  19. return {
  20. height: "400px", // 需要固定swiper的高度
  21. tabs: [{name:'全部'}, {name:'奶粉'}, {name:'面膜'}, {name:'图书'}, {name:'果汁'}, {name:'奶瓶'}, {name:'美素'}, {name:'花王'}, {name:'韩蜜'}],
  22. tabIndex: 0 // 当前tab的下标
  23. }
  24. },
  25. methods: {
  26. // 轮播菜单
  27. swiperChange(e){
  28. this.tabIndex = e.detail.current
  29. },
  30. // 获取指定下标的mescroll对象
  31. // getMescroll(i){
  32. // let mescrollItems = this.$refs.mescrollItem;
  33. // if(mescrollItems){
  34. // let item = mescrollItems[i]
  35. // if(item) return item.mescroll
  36. // }
  37. // return null
  38. // }
  39. },
  40. onLoad() {
  41. // 需要固定swiper的高度
  42. this.height = uni.getSystemInfoSync().windowHeight + 'px'
  43. },
  44. onShow() {
  45. // 返回刷新: https://www.mescroll.com/uni.html#note 第二点
  46. // if(this.canReset){
  47. // let curMescroll = this.getMescroll(this.tabIndex)
  48. // curMescroll && curMescroll.resetUpScroll()
  49. // }
  50. // this.canReset = true
  51. }
  52. }
  53. </script>
  54. <style>
  55. </style>