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

相关推荐
码农学院21 小时前
微信小程序云开发实战:扫码点餐系统的高并发订单处理与外卖接单架构
微信小程序·架构·notepad++
乐橙开放平台2 天前
明厨亮灶笔记:乐橙轻应用 H5 + 小程序插件,一套 BFF 出两张播放凭证
人工智能·笔记·物联网·小程序·音视频·notepad++
梦幻通灵4 天前
Notepad++格式化Json两种方案【持续更新】
android·json·notepad++
alxraves5 天前
零代码AI助手:用大模型自动生成微信小程序界面与逻辑
人工智能·微信小程序·notepad++
AI行业学习10 天前
OpenAI Codex 完整下载 & 安装指南(2026最新版)
linux·开发语言·python·.net·notepad++
qq57521731912 天前
Notepad++下载和安装
笔记·notepad++·记事本
猎人在吃肉14 天前
Notepad++ 快捷键配置文件的导入和导出
notepad++·导出·快捷键·导入·配置文件
2601_9620549514 天前
2026最新5款AI编程工具平替实测合集
人工智能·notepad++·ai编程
AI行业学习16 天前
Notepad++ 官方纯净下载+完整安装教程
linux·开发语言·python·html·.net·notepad++
AI行业学习17 天前
Notepad++ 官方纯净下载+完整安装教程(Windows)【2026.7.5】
开发语言·windows·python·前端框架·html·notepad++