swiper插件,把轮播图的按钮自定义样式图片之后怎么设置大小?
下图为两个自定义的按钮
代码部分
控制台审查元素,看这个的css,他默认有个背景图,先去掉,再覆盖一下样式
<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()
})
}