uview里面轮播图实现缩略图功能

提示:uview里面轮播图实现缩略图功能


前言

使用uview组件库实现轮播图下面缩略图功能;


一、如何使用

1.效果图展示

在这里插入图片描述

2.实现

代码如下(示例):

<view class="topBox">
      <u-swiper :list="urls2" keyName="url" :current="currentBig" :autoplay="false" @change="swiperChange" class="swiper-img">
      </u-swiper>
      //底部的缩略图
      <view class="smallBox">
        <view v-for="(item, index) in urls2" :key="index" class="smallBoxImg" @click="smallClick(item, index)">
          <image :src="item.url" alt="" :class="currentBig === index ? 'smallImg2' : 'smallImg'"></image>
        </view>
      </view>
</view>

data() {
    return {
      currentBig: '',
      currentSmall: '',
      urls2: [],
    }
  },

 mounted() {
    // 默认选中第一项
    this.currentBig = 0
  },

methods: {
   swiperChange(e) {
      console.log(e.current, '9777')
      this.currentBig = e.current
    },
    smallClick(item, index) {
      this.$nextTick(() => {
        this.currentBig = index
      })
    },
}
.topBox {
  width: 100%;
  height: 710rpx;
  position: relative;
}
.topImage {
  width: 100%;
  height: 176rpx;
  background-size: cover;
  z-index: 99;
}
.swiper-img {
  width: 100%;
  height: 700rpx !important;
  position: absolute;
  top: 0;
  /deep/ .u-swiper__wrapper {
    width: 100%;
    height: 700rpx !important;
  }

  /deep/ .u-swiper__wrapper__item__wrapper__image {
    width: 100%;
    height: 700rpx !important;
  }
  /deep/ .u-swiper__wrapper__item__wrapper__image div {
    width: 100%;
    height: 100%;
  }
}
.smallBox {
  width: 100%;
  height: 100rpx;
  position: absolute;
  top: 580rpx;
  z-index: 999;
  display: flex;
  padding: 0 26rpx;
  align-items: center;
  overflow: hidden;
}
.smallBoxImg {
  margin-right: 16rpx;
}
.smallImg {
  width: 60rpx;
  height: 60rpx;
  background-size: cover;
  border-radius: 10rpx;
  box-shadow: 0rpx 4rpx 32rpx 0rpx rgba(47, 43, 43, 0.5);
}
.smallImg2 {
  width: 82rpx;
  height: 82rpx;
  background: #ffffff;
  border-radius: 10rpx;
  box-shadow: 0rpx 4rpx 32rpx 0rpx rgba(47, 43, 43, 0.5);
}

底部的缩略图是自己写的,官网组件库里面的u-swiper没有自带的缩略图功能;或者使用第三方插件;


  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值