综合办公系统
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view>
  3. <!-- 菜单 -->
  4. <view class="top-warp">
  5. <view class="tip">每个菜单列表仅初始化一次,切换菜单缓存数据</view>
  6. <!-- 当设置tab-width,指定每个tab宽度时,则不使用flex布局,改用水平滑动 -->
  7. <me-tabs v-model="tabIndex" :tabs="tabs" @change="tabChange" :tab-width="130"></me-tabs>
  8. </view>
  9. <!-- 子组件 (i: 每个tab页的专属下标; index: 当前tab的下标) -->
  10. <!-- 如果每个子组件布局不一样, 可拆开写 (注意ref只能为 "mescrollItem下标" 的格式, 另外 :i="下标" :index="tabIndex"也是固定写法) : -->
  11. <!-- <home ref="mescrollItem0" :i="0" :index="tabIndex"></home>
  12. <shopcart ref="mescrollItem1" :i="1" :index="tabIndex"></shopcart>
  13. <user ref="mescrollItem2" :i="2" :index="tabIndex"></user> -->
  14. <mescroll-item ref="mescrollItem0" :i="0" :index="tabIndex" :tabs="tabs"></mescroll-item>
  15. <mescroll-item ref="mescrollItem1" :i="1" :index="tabIndex" :tabs="tabs"></mescroll-item>
  16. <mescroll-item ref="mescrollItem2" :i="2" :index="tabIndex" :tabs="tabs"></mescroll-item>
  17. <mescroll-item ref="mescrollItem3" :i="3" :index="tabIndex" :tabs="tabs"></mescroll-item>
  18. <mescroll-item ref="mescrollItem4" :i="4" :index="tabIndex" :tabs="tabs"></mescroll-item>
  19. <mescroll-item ref="mescrollItem5" :i="5" :index="tabIndex" :tabs="tabs"></mescroll-item>
  20. <mescroll-item ref="mescrollItem6" :i="6" :index="tabIndex" :tabs="tabs"></mescroll-item>
  21. <mescroll-item ref="mescrollItem7" :i="7" :index="tabIndex" :tabs="tabs"></mescroll-item>
  22. <mescroll-item ref="mescrollItem8" :i="8" :index="tabIndex" :tabs="tabs"></mescroll-item>
  23. <!-- 如果每个子组件布局一样, 则可使用v-for (注意v-for的ref="mescrollItem"必须是固定值; 另外支付宝小程序不支持此v-for的写法)-->
  24. <!-- <mescroll-item ref="mescrollItem" v-for="(tab,i) in tabs" :key="i" :i="i" :index="tabIndex" :tabs="tabs"></mescroll-item> -->
  25. </view>
  26. </template>
  27. <script>
  28. import MescrollItem from "./mescroll-more-item.vue";
  29. import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
  30. export default {
  31. mixins: [MescrollMoreMixin], // 多个mescroll-body写在子组件时, 则使用mescroll-more.js补充子组件的页面生命周期
  32. components: {
  33. MescrollItem
  34. },
  35. data() {
  36. return {
  37. tabs: [{name:'全部'}, {name:'奶粉'}, {name:'面膜'}, {name:'图书'}, {name:'果汁'}, {name:'奶瓶'}, {name:'美素'}, {name:'花王'}, {name:'韩蜜'}],
  38. tabIndex: 0 // 当前tab下标,必须与mescroll-more.js对应,所以tabIndex是固定变量,不可以改为其他的名字
  39. }
  40. },
  41. onShow() {
  42. // 返回刷新: https://www.mescroll.com/uni.html#note 第二点
  43. // if(this.canReset){
  44. // let curMescroll = this.getMescroll(this.tabIndex)
  45. // curMescroll && curMescroll.resetUpScroll()
  46. // }
  47. // this.canReset = true
  48. }
  49. }
  50. </script>
  51. <style>
  52. .top-warp{
  53. z-index: 9990;
  54. position: fixed;
  55. top: --window-top; /* css变量 */
  56. left: 0;
  57. width: 100%;
  58. height: 120upx;
  59. background-color: white;
  60. }
  61. .top-warp .tip{
  62. font-size: 28upx;
  63. height: 60upx;
  64. line-height: 60upx;
  65. text-align: center;
  66. }
  67. </style>