swiper插件,把轮播图的按钮自定义样式图片之后怎么设置大小

swiper插件,把轮播图的按钮自定义样式图片之后怎么设置大小?

下图为两个自定义的按钮

img

代码部分

img

控制台审查元素,看这个的css,他默认有个背景图,先去掉,再覆盖一下样式

  • 这个问题的回答你可以参考下: https://ask.csdn.net/questions/7729510
  • 这篇博客你也可以参考下:swiper轮播,小轮播图,点击变大轮播图(小图变大图)
  • 除此之外, 这篇博客: 微信小程序swiper实现间距轮播中的 样式三: 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 在这里插入图片描述

    <swiper class="banner-container" circular="true" previous-margin="100rpx" next-margin="100rpx" current="{{currentBannerIndex}}" bindchange="handleChangeBanner">
            <block wx:for="{{imgList}}" wx:key="this">
              <swiper-item class="banner-item">
                <view class="banner-box" animation="{{currentBannerIndex == index ? animationSelected : animationNoSelected}}">
                  <image src="{{item.imgSrc}}" class="banner-img"></image>
                </view>
              </swiper-item>
            </block>
    </swiper>
    
    .banner-container{
      width: 100%;
      height: 600rpx;
    }
    .banner-item{
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .banner-box{
      width: 90%;
      height: 100%;
    }
    .banner-img{
      width: 100%;
      height: 100%;
    }
    
    data:{
    	currentBannerIndex: 0
    },
    onShow(option){
        this.enlarge();
        this.shrink();
    },
    // 轮播图切换
    handleChangeBanner(e){
        this.setData({
          currentBannerIndex: e.detail.current
        })
    
    	//当下标相同执行方法动画,下标不同执行缩小动画
        this.enlarge();
        this.shrink();
    },
    // 轮播图缩小动画
    shrink(){
        const animationNoSelected = wx.createAnimation({
          duration: 1000,
          timingFunction: 'ease'
        })
        animationNoSelected.height('530rpx').step();
        this.setData({
          animationNoSelected: animationNoSelected.export()
        })
    },
    // 轮播图放大动画
    enlarge(){
        const animationSelected = wx.createAnimation({
          duration: 1000,
          timingFunction: 'ease'
        })
        animationSelected.height('600rpx').step();
        this.setData({
          animationSelected: animationSelected.export()
        })
    }
    
  • 您还可以看一下 汤小洋老师的Swiper移动端滑动插件视频教程课程中的 Swiper简介小节, 巩固相关知识点