小程序宿主环境-组件swiper

巧识小程序的开发过程学习.


在我们的list.wxml中创建组件

html 复制代码
<swiper class="swiper-container" indicator-dots indicator-color="white" indicator-active-color="grey" 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>

在我们list.wxss创建样式

css 复制代码
/* pages/list/list.wxss */
.swiper-container{
height: 150px;
}
.item{
height: 100%;
line-height: 150px;
text-align: center;
}
swiper-item:nth-child(1){
background-color: sandybrown;
}
swiper-item:nth-child(2){
  background-color: rgb(106, 111, 158);
}
swiper-item:nth-child(3){
  background-color: rgb(136, 41, 48);
  }

效果实现轮播图

swiper组件的常用属性

属性indicator-dots:是否显示面板指示点

属性indicator-color:指示点颜色

属性indicator-active-color:指示点激活颜色

属性autoplay:是否自动切换

属性interval:自动切换的时间默认5s

属性circular:是否循环轮播

相关推荐
爱学习 爱分享9 小时前
微信小程序html 在 webview 会打开再缩放一下
微信小程序·小程序·html
梦梦代码精10 小时前
深度拆解:上门按摩系统如何成为本地生活“到家时代”的新引擎?
docker·小程序·uni-app·开源·生活·开源软件
Geek_Vison11 小时前
如何借助小程序容器技术实现跨端APP的敏捷开发
小程序·apache·敏捷流程
xshirleyl12 小时前
微信小程序开发week6-慕尚花坊项目
微信小程序·小程序
usdoc文档预览12 小时前
国产化踩坑:Vue3 / React / 小程序如何免插件实现 OFD 及复杂 Office 文档同屏预览
前端·javascript·react.js·小程序·pdf·word·office文件在线预览
倒流时光三十年12 小时前
第二章 小程序目录结构与核心文件详解
spring boot·小程序
好赞科技14 小时前
2026年八大上门服务预约小程序:解锁高效生活新体验
大数据·微信小程序
维双云14 小时前
从零到一:一份关于“做小程序的步骤”的完整实操指南
小程序
编程猪猪侠14 小时前
uni-app微信小程序车牌号输入组件实现
微信小程序·uni-app
客场消音器1 天前
如何使用codex进行UI重构,让AI开发的前端页面不再千篇一律
前端·后端·微信小程序