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

相关推荐
suncentwl3 分钟前
为什么选择有版权的答题pk小程序
小程序·答题小程序·答题pk
小旋风0123442 分钟前
uniapp自定义头部(兼容微信小程序(胶囊和状态栏),兼容h5)
微信小程序·uni-app·notepad++
GalenZhang8883 小时前
Java生成微信小程序码及小程序短链接
java·微信小程序·小程序
浮桥4 小时前
uniapp -- 实现微信小程序、app、H5端视频上传
微信小程序·uni-app·音视频
说私域6 小时前
从大众传媒到数字生态:开源AI智能名片链动2+1模式S2B2C商城小程序驱动的营销革命
人工智能·小程序·开源·零售
换日线°6 小时前
微信小程序连续多个特殊字符自动换行解决方法
微信小程序
海拥7 小时前
《用Cursor和AI绘画24小时开发壁纸小程序》详细开发实录
微信小程序·cursor
10年前端老司机10 小时前
微信小程序behaviors
前端·javascript·微信小程序
山河故人16310 小时前
基于 SSE 和分块传输的 Uniapp 微信小程序 实现 流式传输 对话
微信小程序·小程序·uni-app
10年前端老司机11 小时前
微信小程序自定义组件
前端·javascript·微信小程序