初识微信小程序之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源码3 天前
家乡介绍小程序
小程序·notepad++
niucloud-admin4 天前
NIUCLOUD LITE AI开发文档—模块开发:微信小程序
微信小程序·小程序·notepad++
江湖有缘4 天前
Docker实战 | Docker部署Minimalist-web-notepad个人笔记本
前端·docker·notepad++
知码者9 天前
uni-app小程序商城实战:从0到1
notepad++
xunyan623410 天前
3-1 独立按键控制LED状态(SDCC + Notepad++ + STC-ISP/普中ISP)
notepad++·接口隔离原则
一木 之林10 天前
微信小程序开发全攻略·文章版|01 入门与环境搭建
人工智能·学习·计算机视觉·微信小程序·notepad++
xunyan623414 天前
51 单片机LED闪烁(SDCC + Notepad++ + STC-ISP/普中ISP)
单片机·notepad++·接口隔离原则
liangshanbo121516 天前
前端面试题:微信小程序怎么优化性能?
前端·微信小程序·notepad++
吠品21 天前
CSS图片模糊过渡:一个transition加filter就够
java·数据库·notepad++
网硕互联的小客服24 天前
微信小程序多种跳转页面方式教学
微信小程序·小程序·notepad++