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

相关推荐
山语山4 天前
微信小程序 蓝牙通讯
网络·微信小程序·小程序·github·notepad++
程序手艺人5 天前
Notepad++ 之 AndroidLogger插件
notepad++
迷雾yx6 天前
开发微信小程序 案例01-本地生活首页页面
微信小程序·生活·notepad++·xss
灯火不休ᝰ6 天前
[Notepad++] 文本编辑器的下载及详细安装使用过程(附有下载文件)
notepad++
无敌开心7 天前
微信小程序开发第八课
微信小程序·小程序·notepad++
diygwcom7 天前
扩展uview复选组件库支持自定义图片+自定义内容
notepad++
战神刘玉栋8 天前
《微信小程序实战(4) · 地图导航功能》
微信小程序·小程序·notepad++
前端 贾公子9 天前
微信小程序的 button 标签的边框如何去除?
微信小程序·小程序·notepad++
李宥小哥10 天前
微信小程序03-页面交互
微信小程序·交互·notepad++
CC同学呀12 天前
基于微信小程序的竞赛答题小程序开发笔记(一)
笔记·微信小程序·notepad++