武装少女在线观看高清完整版免费,丝袜+亚洲区,少妇被cao高潮呻吟声,午夜伦情电午夜伦情电影,日日躁夜夜躁狠狠躁

小程序模板網(wǎng)

微信小程序之 swiper自定義dot

發(fā)布時(shí)間:2021-06-29 09:06 所屬欄目:小程序開發(fā)教程

微信自帶的swiper不支持dot樣式修改,如果UI設(shè)計(jì)的樣式有變化,將很難自定義
以下,提供一種方案來解決dot樣式自定義的問題
如圖:

大致思路 就是隱藏默認(rèn)swiper的dots,然后自定義自己的dotview,并同步事件

<!--index.wxml-->
<view class="swiper-container">
  <swiper autoplay="{{autoplay}}" 
  circular="{{true}}"
  indicator-dots="{{false}}" 
  current="{{swiperCurrent}}" vertical="{{false}}" bindchange="swiperChange">
    <block wx:for="{{imgUrls}}">
      <swiper-item>
        <image src="{{item}}" mode="widthFix"></image>
      </swiper-item>
    </block>
  </swiper>
  <view wx:if="{{imgUrls.length > 1}}" class="dots-container">
    <block wx:for="{{imgUrls}}">
       <view class="dot{{index == swiperCurrent ? ' active' : ''}}" bind:tap="onDotTap" mark:index="{{index}}"></view>
    </block>
  </view>
</view>
//index.js
Page({
  data: {
    autoplay:true,
    swiperCurrent: 0,
    imgUrls: [
      '','','',''
    ]
  },
  swiperChange: function (e) {
    let that = this;
    that.setData({
      swiperCurrent: e.detail.current
    })
  },
  onDotTap(e){
    this.setData({autoplay:false});
    console.log(e);
    const {index} = e.mark;
    //設(shè)置滾動(dòng)
    this.setData({swiperCurrent:index,autoplay:true});
  }
})
/**index.wxss**/
.swiper-container{
  position: relative;
}
swiper{
  height: 300rpx;
  background-color: orange;
}
swiper-item{
  height: 100%;
  width: 100%;
  background-color: blue;
}
swiper-item image{
  width: 100%;
  height: 100%;
}
swiper-item:nth-child(1){
  background-color: chartreuse;
}
swiper-item:nth-child(2){
  background-color: red;
}
swiper-item:nth-child(3){
  background-color: rebeccapurple;
}
swiper-item:nth-child(4){
  background-color: cyan;
}
.dots-container{
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  bottom: 10rpx;
  left:50%;
  transform:translate(-50%);
  /* background-color: gray; */
}
.dot{
  height: 20rpx;
  width: 20rpx;
  background-color: #9A9A9A;
  border-radius: 10rpx;
  margin-left: 20rpx;
  transition: all .25s;
  box-sizing: border-box;
  border:1rpx solid white;
}
.dot.active{
  width: 40rpx;
  background: #fff;
}
.dot:nth-of-type(1){
  margin-left: 0;
}


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.kknew.com.cn/wxmini/doc/course/26820.html 復(fù)制鏈接 如需定制請(qǐng)聯(lián)系易優(yōu)客服咨詢:800182392 點(diǎn)擊咨詢
QQ在線咨詢
AI智能客服 ×