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

相关推荐
超超~~1 天前
Notepad(文本编辑器)v3.6.30绿色官方版
编辑器·notepad++
一室易安1 天前
uniapp+vue3 微信小程序中 页面切换tab 页面滚动到指定锚点位置,滚动页面时候到达指定锚点位置吸顶tab 会自动进行切换
微信小程序·uni-app·notepad++
admin and root2 天前
渗透测试 | 分享某次项目上的渗透测试漏洞复盘
渗透测试·notepad++·漏洞挖掘·红蓝对抗·攻防演练·护网·爆破密码
何包蛋H4 天前
医疗视频播放组件开发实战:支持病灶标注、缓存播放与性能优化
微信小程序·音视频·notepad++
桐溪漂流4 天前
微信小程序的几个实用小知识
微信小程序·小程序·notepad++
han_hanker9 天前
svg 可改颜色,但似乎不支持微信小程序
微信小程序·小程序·notepad++
默魔20 天前
uniapp canvas 生成海报并保存到相册
uni-app·notepad++
JIngJaneIL23 天前
停车场管理|停车预约管理|基于Springboot+的停车场管理系统设计与实现(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·notepad++·停车场管理|
一人一程温一壶酒1 个月前
微信小程序uniapp开发附源码——图片加水印
微信小程序·uni-app·notepad++
LXA08091 个月前
UniApp 小程序中使用地图组件
小程序·uni-app·notepad++