uniapp微信小程序之轮播图效果

本文介绍了如何利用Swiper组件和swiper-item组件在小程序中实现轮播图效果。详细讲解了swiper的重要属性,如indicator-dots、indicator-color、indicator-active-color、autoplay、interval和circular,并提供了相应的WXML和WXSS代码示例,展示了如何设置不同背景色的轮播项。
摘要由CSDN通过智能技术生成

使用轮播图效果需要用到swiper组件和swiper-item组件

首先需要了解swiper组件的常用属性

indicator-dots  是否显示轮播图下的小圆点

indicator-color  未被选中的小圆点的颜色

indicator-acive-color  已被选中的小圆点的颜色

autoplay  是否允许轮播图自动切换 默认false 如果需要自动切换直接写上 不用给值

interval  是否切换图片切换时间 默认时间5秒 2000=2秒

circular  是否采用衔接滚动 从第一张可以倒回最后一张 默认false

wxml部分:

<swiper class="lunb" indicator-dots indicator-color="#fff" indicator-active-color="red" autoplay interval="2000" circular>
  <swiper-item>
    <view class="item">a</view>
  </swiper-item>
  <swiper-item>
    <view class="item">b</view>
    </swiper-item>
  <swiper-item>
    <view class="item">c</view>
  </swiper-item>
</swiper>

wxss部分:

.lunb {
  height: 150px;
}
.lunb .item {
  height: 100%;
  text-align: center;
  line-height: 150px;
}
swiper-item:nth-child(1) .item {
  background-color: skyblue;
}
swiper-item:nth-child(2) .item {
  background-color: pink;
}
swiper-item:nth-child(3) .item {
  background-color: purple;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值