微信小程序如何使用swiper组件实现图片轮播切换显示功能

这篇文章将为大家详细讲解有关微信小程序如何使用swiper组件实现图片轮播切换显示功能,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

具体如下:

1、效果展示

微信小程序如何使用swiper组件实现图片轮播切换显示功能

2、关键代码

index.wxml:

<swiper indicator-dots="true"autoplay="true" interval="3000" duration="600" >
 <swiper-item>
 <image src="../../pages/images/img1.png" />
 </swiper-item>
 <swiper-item>
 <image src="../../pages/images/img2.png" />
 </swiper-item>
 <swiper-item>
 <image src="../../pages/images/img3.png" />
 </swiper-item>
</swiper>

swiper组件属性说明如下:

属性名 类型 默认值 说明 最低版本
indicator-dots Boolean false 是否显示面板指示点
indicator-color Color rgba(0, 0, 0, .3) 指示点颜色 1.1.0
indicator-active-color Color #000000 当前选中的指示点颜色 1.1.0
autoplay Boolean false 是否自动切换
current Number 0 当前所在页面的 index
interval Number 5000 自动切换时间间隔
duration Number 500 滑动动画时长
circular Boolean false 是否采用衔接滑动
vertical Boolean false 滑动方向是否为纵向
bindchange EventHandle
current 改变时会触发 change 事件,event.detail = {current: current, source: source}

关于“微信小程序如何使用swiper组件实现图片轮播切换显示功能”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。