初识微信小程序之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>

相关推荐
【ql君】qlexcel2 天前
Notepad++ 复制宏、编辑宏的方法
开发语言·javascript·notepad++··宏编辑·宏复制
程序员陆通2 天前
Vibe Coding开发微信小程序实战案例
微信小程序·小程序·notepad++·ai编程
nbsaas-boot2 天前
[特殊字符] 分享裂变新姿势:用 UniApp + Vue3 玩转小程序页面分享跳转!
小程序·uniapp·notepad++
唯独不开心11 天前
NotePad++ 怎么没有找到插件管理?
notepad++
橘子海全栈攻城狮11 天前
【源码+文档+调试讲解】基于web的运动健康小程序的设计与实现y196
java·开发语言·小程序·notepad++
lyh134414 天前
跨平台的重构版Notepad++文本编辑器
重构·notepad++
小妖66614 天前
notepad++ 安装插件下载进度为0怎么处理?
notepad++
逆风优雅14 天前
微信小程序使用rsa 加解密
微信小程序·小程序·notepad++
kq-blue14 天前
uniapp开发小程序,导出文件打开并保存,实现过程downloadFile下载,openDocument打开
小程序·uni-app·notepad++
莫魂魂18 天前
003微信小程序视图与逻辑
微信小程序·小程序·notepad++