初识微信小程序之swiper和swiper-item的基本使用

在我还没接触到微信小程序之前,通常使用轮播要么手写或使用swiper插件去实现,当我接触到微信小程序之后,我看到了微信小程序的强大之处,让我为大家介绍一下吧!

swiper与swiper-item一起使用可以做轮播图

基本使用,上代码:

<swiper class="swiper-container">

<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>

样式

.swiper-container {

height: 150px;

}

.item{

height: 100%;

text-align: center;

line-height: 150px;

}

swiper-item:nth-child(1) .item{

background-color: pink;

}

swiper-item:nth-child(2) .item{

background-color: red;

}

swiper-item:nth-child(3) .item{

background-color: gold;

}

swiper当中常用的属性

属性 类型 默认值 说明

indicator-dots boolean false 是否显示面板指示点

indicator-color color rgba(0, 0, 0,.3) 指示点颜色

indicator-active-color color false 当前选中的指示点颜色

autoplay boolean false 是否自动切换

interval number 5000 自动切换时间间隔

circular boolean false 是否采用衔接滑动

<!-- 属性 indicator-dots -->

<swiper class="swiper-container" 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>

相关推荐
小新11013 小时前
微信小程序 密码框改为text后不可见,需要点击一下
微信小程序·小程序·notepad++
AALoveTouch4 天前
霸王茶姬微信小程序自动化签到系统完整实现&解析
微信小程序·自动化·notepad++
Mark.10245 天前
uniapp项目打包的微信小程序,设置uni-popup type=“bottom“时,底部有空隙
微信小程序·uni-app·notepad++
痞老板人小心大6 天前
书法机构用的教务管理系统
notepad++·教务管理系统·教务·教务系统
ice breaker8 天前
weapp-vite - 微信小程序工具链的另一种选择
微信小程序·小程序·notepad++
木子金光军9 天前
Doo全自动手机壳定制系统
notepad++
gewen_198811 天前
绿色版的notepad++怎么加入到右键菜单里
notepad++
mon_star°12 天前
网络安全知识问答微信小程序的设计与实现
web安全·微信小程序·notepad++
小旋风0123415 天前
uniapp自定义头部(兼容微信小程序(胶囊和状态栏),兼容h5)
微信小程序·uni-app·notepad++