nav.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-gradual-pink" :isBack="true"><block slot="backText">返回</block><block slot="content">导航栏</block></cu-custom>
  4. <view v-for="(item,index) in 10" :key="index" v-if="index==TabCur" class="bg-grey padding margin text-center">
  5. Tab{{index}}
  6. </view>
  7. <view class="cu-bar bg-white solid-bottom">
  8. <view class="action">
  9. <text class="cuIcon-title text-orange"></text> 默认
  10. </view>
  11. </view>
  12. <scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft">
  13. <view class="cu-item" :class="index==TabCur?'text-green cur':''" v-for="(item,index) in 10" :key="index" @tap="tabSelect" :data-id="index">
  14. Tab{{index}}
  15. </view>
  16. </scroll-view>
  17. <view class="cu-bar bg-white margin-top solid-bottom">
  18. <view class="action">
  19. <text class="cuIcon-title text-orange"></text> 居中
  20. </view>
  21. </view>
  22. <scroll-view scroll-x class="bg-white nav text-center">
  23. <view class="cu-item" :class="index==TabCur?'text-blue cur':''" v-for="(item,index) in 3" :key="index" @tap="tabSelect" :data-id="index">
  24. Tab{{index}}
  25. </view>
  26. </scroll-view>
  27. <view class="cu-bar bg-white margin-top solid-bottom">
  28. <view class="action">
  29. <text class="cuIcon-title text-orange"></text> 平分
  30. </view>
  31. </view>
  32. <scroll-view scroll-x class="bg-white nav">
  33. <view class="flex text-center">
  34. <view class="cu-item flex-sub" :class="index==TabCur?'text-orange cur':''" v-for="(item,index) in 4" :key="index" @tap="tabSelect" :data-id="index">
  35. Tab{{index}}
  36. </view>
  37. </view>
  38. </scroll-view>
  39. <view class="cu-bar bg-white margin-top solid-bottom">
  40. <view class="action">
  41. <text class="cuIcon-title text-orange"></text> 背景
  42. </view>
  43. </view>
  44. <scroll-view scroll-x class="bg-red nav text-center">
  45. <view class="cu-item" :class="index==TabCur?'text-white cur':''" v-for="(item,index) in 3" :key="index" @tap="tabSelect" :data-id="index">
  46. Tab{{index}}
  47. </view>
  48. </scroll-view>
  49. <view class="cu-bar bg-white margin-top solid-bottom">
  50. <view class="action">
  51. <text class="cuIcon-title text-orange"></text> 图标
  52. </view>
  53. </view>
  54. <scroll-view scroll-x class="bg-green nav text-center">
  55. <view class="cu-item" :class="0==TabCur?'text-white cur':''" @tap="tabSelect" data-id="0">
  56. <text class="cuIcon-camerafill"></text> 数码
  57. </view>
  58. <view class="cu-item" :class="1==TabCur?'text-white cur':''" @tap="tabSelect" data-id="1">
  59. <text class="cuIcon-upstagefill"></text> 排行榜
  60. </view>
  61. <view class="cu-item" :class="2==TabCur?'text-white cur':''" @tap="tabSelect" data-id="2">
  62. <text class="cuIcon-clothesfill"></text> 皮肤
  63. </view>
  64. </scroll-view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. TabCur: 0,
  72. scrollLeft: 0
  73. };
  74. },
  75. methods: {
  76. tabSelect(e) {
  77. this.TabCur = e.currentTarget.dataset.id;
  78. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
  79. }
  80. }
  81. }
  82. </script>
  83. <style>
  84. </style>