使用轮播图效果需要用到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;
}