初识微信小程序之swiper和swiper-item的基本使用

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值