uniapp 导航栏和内容同时轮播以及图片轮播中间大两边小


不多所代码提上

<template>
  <view class="container">
    <view class="row">
      <view
        class="item"
        v-for="(item,index) in activeItem"
        :key="index"
        @click="currentIndex=index"
                :class="item.active?'active':null"
      >{{item.name}}</view>
    </view>
    <swiper class="swiperPage" :current="currentIndex" @change="swiperTab">
      <swiper-item>
        <view class="swiper-item">A</view>
      </swiper-item>
      <swiper-item>
        <view class="swiper-itemB">B</view>
      </swiper-item>
    </swiper>
    <swiper class="swiper" circular :current="currentIndex" @change="swiperTab" previous-margin="100rpx"
            next-margin="100rpx">
      <swiper-item v-for="(info,num) in [1,2,3,4]" :key="num">
        <view class="swiper-item" :class="currentIndex===num?'active':null">A</view>
      </swiper-item>
    </swiper>
  </view>
</template>

<script>
export default {
  data () {
    return {
      title: 'Hello',
      currentIndex: 0,
      activeItem: [{ name: "精选", active: true }, { name: "关注", active: false }]
    }
  },
  onLoad () {

  },
  methods: {
    swiperTab (e) {
            this.currentIndex = e.detail.current //获取索引
            this.activeItem.forEach((item,index)=>{
                if(index===this.currentIndex){
                    item.active = true
                }else{item.active = false}
            })
    },

  }
}
</script>
 <style lang="scss">
.container {
  height: 100vh;
  width: 100%;
  background: hotpink;
  .row {
    display: flex;
    align-items: center;
    height: 56rpx;
    width: 100%;
    background: blue;
        padding-left: 100upx;
    .item {
      margin-right: 100upx;
      color: red;
            &.active{
                border-bottom: 2rpx solid red;
            }
    }
  }
  .swiperPage {
    height: 300upx;
    width: 100%;
    .swiper-item {
      height: 100%;
      background: black;
    }
    .swiper-itemB {
      height: 100%;
      background: yellow;
    }
  }
    .swiper{
        margin-top: 20upx;
        height: 700rpx;
        width: 100%;
        .swiper-item{
            height: 40%;
            width: 90%;
            opacity: .4;
            background: yellow;
            border-radius: 20rpx;
            margin: 10rpx 20upx;
            &.active{
                transform: scale(1.1);
                transition: all 0.2s ease-in 0s;
                opacity: 1;
                background: red;
                border-radius: 20rpx;
            }
        }
    }
}
</style>

 

 可根据自己的需求自动调样式,


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM