当前位置:   article > 正文

uniapp-tab栏切换_uni-app组件tabs切换

uni-app组件tabs切换
  1. <view class="viewport">
  2. <!-- tabs -->
  3. <view class="tabs">
  4. <text class="item" v-for="(item, index) in orderTabs" :key="item.title" @tap="taphadle(index)">
  5. {{ item.title }}
  6. </text>
  7. <!-- 游标 -->
  8. <view class="cursor" :style="{ left: activeIndex * 20.5 + '%',width:'15px'}"></view>
  9. </view>
  10. <!-- 滑动容器 -->
  11. <swiper class="swiper" :current="activeIndex" @change="activeIndex = $event.detail.current" style="height: 800px;">
  12. <!-- 滑动项 -->
  13. <swiper-item v-for="item in 5" :key="item">
  14. //滑动页中的每一项
  15. </swiper-item>
  16. </swiper>
  17. </view>
  1. page {
  2. height: 100%;
  3. overflow: hidden;
  4. }
  5. .viewport {
  6. height: 100%;
  7. display: flex;
  8. flex-direction: column;
  9. background-color: #fff;
  10. }
  11. // tabs
  12. .tabs {
  13. display: flex;
  14. justify-content: space-around;
  15. line-height: 60rpx;
  16. margin: 0 10rpx;
  17. background-color: #fff;
  18. box-shadow: 0 4rpx 6rpx rgba(240, 240, 240, 0.6);
  19. position: relative;
  20. z-index: 9;
  21. .item {
  22. flex: 1;
  23. text-align: center;
  24. padding: 20rpx;
  25. font-size: 28rpx;
  26. color: #262626;
  27. }
  28. .cursor {
  29. position: absolute;
  30. left: 0;
  31. bottom: 0;
  32. width: 20%;
  33. height: 6rpx;
  34. padding: 0 50rpx;
  35. background-color: #27ba9b;
  36. /* 过渡效果 */
  37. transition: all 0.4s;
  38. }
  39. }
  40. // swiper
  41. .swiper {
  42. background-color: #f7f7f8;
  43. }
  44. .container {
  45. overflow: hidden;
  46. }
  47. .uni-body {
  48. font-size: 10px;
  49. margin-right: 60px;
  50. }
  1. data() {
  2. return {
  3. activeIndex: 1,//tab索引项
  4. type: 0,//页面传参tab项
  5. itemsArray: [],//暂时存储商品列表项
  6. itemss: [],//存储商品列表项
  7. orderTabs: [{
  8. orderState: 0,
  9. title: '全部'
  10. },
  11. {
  12. orderState: 1,
  13. title: '待付款'
  14. },
  15. {
  16. orderState: 2,
  17. title: '待发货'
  18. },
  19. {
  20. orderState: 3,
  21. title: '待收货'
  22. },
  23. {
  24. orderState: 4,
  25. title: '待评价'
  26. },
  27. ],
  28. };
  29. },
  1. onLoad() {
  2. this.activeIndex = this.orderTabs.findIndex(tab => tab.orderState === this.type);
  3. }
  4. methods:{
  5. //点击tab栏事件
  6. async taphadle(index) {
  7. this.activeIndex = index
  8. }
  9. }

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

闽ICP备14008679号