小程序宿主环境-组件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:是否循环轮播

相关推荐
明月_清风4 小时前
小程序云函数:从入门到全栈的“降维打击”指南
前端·微信小程序·小程序·云开发
拉不动的猪14 小时前
移动端调试工具VConsole初始化时的加载阻塞问题
前端·javascript·微信小程序
WangHappy3 天前
不写 Canvas 也能搞定!小程序图片导出的 WebView 通信方案
前端·微信小程序
小时前端3 天前
微信小程序选不了本地文件?用 web-view + H5 一招搞定
前端·微信小程序·uni-app
icebreaker4 天前
Weapp-vite:原生模式之外,多一种 Vue SFC 选择
前端·vue.js·微信小程序
icebreaker4 天前
重走 Vue 长征路 Weapp-vite:编译链路与 Wevu 运行时原理拆解
前端·vue.js·微信小程序
大米饭消灭者7 天前
Taro是怎么实现一码多端的【底层原理】
微信小程序·taro
FliPPeDround8 天前
Vitest Environment UniApp:让 uni-app E2E 测试变得前所未有的简单
微信小程序·e2e·前端工程化
FliPPeDround8 天前
微信小程序自动化的 AI 新时代:wechat-devtools-mcp 智能方案
微信小程序·ai编程·mcp
吴声子夜歌8 天前
小程序——布局示例
小程序