当前位置:   article > 正文

uniapp使用scroll-view与swiper组件实现tab滑动切换页面_uniapp swiper scroll-view

uniapp swiper scroll-view
  1. <view class="uni-flex uni-row jksp-top">
  2. <scroll-view class="scroll1" scroll-x="true">
  3. <view :class="currentTab==index ? 'select' : ''" :data-current="index" @click="swichNav" v-for="(item,index) in scoll" :key='index' class="text1">{{item.txt}}
  4. </view>
  5. </scroll-view>
  6. </view>
  7. <swiper :current="currentTab" @change="bindChange" style="height:470rpx;margin-top:20rpx;">
  8. <swiper-item>
  9. 22
  10. </swiper-item>
  11. <swiper-item>
  12. 33
  13. </swiper-item>
  14. </swiper>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. currentTab: 0,
  20. scoll: [{
  21. txt: '精选1'
  22. }, {
  23. txt: '精选2'
  24. }],
  25. }
  26. }
  27. methods: {
  28. // 滑动页面同步tab栏
  29. bindChange: function(e) {
  30. this.currentTab = e.detail.current
  31. },
  32. //点击tab切换
  33. swichNav: function(e) {
  34. var that = this;
  35. if (this.currentTab === e.target.dataset.current) {
  36. return false;
  37. } else {
  38. this.currentTab = e.target.dataset.current
  39. }
  40. }
  41. }
  42. }
  43. <script>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/312447
推荐阅读
相关标签
  

闽ICP备14008679号