uniapp 卡片式轮播图

html结构:

uniapp自带的swiper 组件可以弄成寻常的轮播图

 

<swiper class="image-container" previous-margin="45rpx"
  next-margin="45rpx" circular autoplay indicator-dots indicator-color="#9d9080"
  indicator-active-color="#fffffb" @change="swiperChange">
  <swiper-item :class="currentIndex == index ? 'swiper-item' : 'swiper-item-side'"
    v-for="(item, index) in imgList" :key="index" lazy-load
    :style="dontFirstAnimation ? 'animation: none;' : ''">
    <view class="item" :class="currentIndex == index ? 'item-img' : 'item-img-side'">
      <image :src="item" alt=""></image>
    </view>
  </swiper-item>
</swiper>

JavaScript结构:

 

export default {   data() {   return {   imgList: [   'https://cdn.uviewui.com/uview/swiper/swiper1.png', 'https://cdn.uviewui.com/uview/swiper/swiper2.png', 'https://cdn.uviewui.com/uview/swiper/swiper3.png', ], //轮播图图片 currentIndex: 0, dontFirstAnimation: true, Inv: 0, navIndex: 0, indicator: true,
     } },

 

css结构:

 

.image-container { width: 750rpx; height: 360rpx; } .item { width: 100%; height: 100%; image { width: 100%; height: 340rpx; border-radius: 20rpx; box-shadow: 2px 2px 18px rgba(0, 0, 0, 0.12); } } .item-img { width: 630rpx; height: 340rpx; border-radius: 14rpx; animation: to-big .3s; } .swiper-item { width: 630rpx; height: 340rpx; display: flex; justify-content: center; align-items: center; } .item-img-side { width: 630rpx; height: 298rpx; border-radius: 14rpx; animation: to-mini .3s; } .swiper-item-side { width: 630rpx; height: 298rpx; display: flex; justify-content: center; align-items: center; } @keyframes to-mini { from { height: 340rpx; } to { height: 298rpx; } } @keyframes to-big { from { height: 298rpx; } to { height: 340rpx; } }

 

最后看看效果

 


__EOF__

本文作者h_h123
本文链接https://www.cnblogs.com/huangjunhua/p/16580963.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   h_h123  阅读(1515)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
点击右上角即可分享
微信分享提示