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

相关推荐
AI行业学习2 小时前
Notepad++ 下载+安装+插件集合 完整教程(Windows,安全无捆绑)
windows·notepad++
ZC跨境爬虫4 天前
模块化烹饪小程序开发日记 Day2:全局配置与 tabBar 实现
java·前端·javascript·微信小程序·html·notepad++
idolao8 天前
npp.8.5.Installer文本编辑器安装步骤详解(附Notepad++配置与插件安装教程)
notepad++
px不是xp9 天前
【灶台导航】 RAG系统的容错设计:从向量搜索到关键词降级,一个都不能少
javascript·微信小程序·notepad++·rag
空中海10 天前
微信小程序 - 03 工程实践层与综合 Demo
微信小程序·小程序·notepad++
舟遥遥娓飘飘12 天前
面向零基础初学者,从环境搭建到发布上线,手把手教你开发第一个微信小程序(第3章-认识项目结构)
微信小程序·小程序·notepad++
优睿远行12 天前
微信小程序自定义组件开发实战:从封装到发布的全流程指南
微信小程序·小程序·notepad++
喜欢南方姑娘15 天前
微信小程序热更新-用户打开小程序时检测版本自动更新
微信小程序·小程序·notepad++
yzx99101315 天前
从零开始写一个微信小程序:完整代码实战指南(入门篇)
微信小程序·小程序·notepad++
fengyehongWorld16 天前
Notepad++ NppExec插件的使用
notepad++