最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

微信小程序修改swiper默认指示器样式的实例代码

来源:动视网 责编:小采 时间:2020-11-27 22:11:16
文档

微信小程序修改swiper默认指示器样式的实例代码

微信小程序修改swiper默认指示器样式的实例代码:修改官方swiper样式 从微信官方微信开发文档中心复制swiper 代码块。 wxml定义 <view class=wrap> <swiper class=swipers autoplay={{autoplay}} current={{currentSwiper}} bindchange=
推荐度:
导读微信小程序修改swiper默认指示器样式的实例代码:修改官方swiper样式 从微信官方微信开发文档中心复制swiper 代码块。 wxml定义 <view class=wrap> <swiper class=swipers autoplay={{autoplay}} current={{currentSwiper}} bindchange=


wxml定义

<view class="wrap">
 <swiper class="swipers" autoplay="{{autoplay}}" current="{{currentSwiper}}" bindchange="swiperChange"> 
 <block wx:for="{{imgUrls}}"> 
 <swiper-item> 
 <image src="{{item}}" class="slide-image" width="100%" height="150" ></image> 
 </swiper-item> 
 </block> 
 </swiper> 
 <!--重置小圆点的样式 -->
 <view class="dots"> 
 <block wx:for="{{imgUrls}}"> 
 <view class="dot{{index == currentSwiper ? ' active' : ''}}"></view> 
 </block> 
 </view> 
</view>

wxss定义样式

.wrap {
 height: auto;
 position: relative;
 width: 100%;
}
.swipers {
 height: 350rpx;
 width: 100%;
}
.slide-image {
 display: block;
 width: 100%;
 height: 100%;
}
/*用来包裹所有的小圆点 */
.dots {
 width: 156rpx;
 height: 36rpx;
 display: flex;
 flex-direction: row;
 position: absolute;
 left: 320rpx;
 bottom: 20rpx;
}
/*未选中时的小圆点样式 */
.dot {
 width: 26rpx;
 height: 26rpx;
 border-radius: 50%;
 margin-right: 26rpx;
 background-color: white;
}
/*选中以后的小圆点样式 */
.active {
 width: 26rpx;
 height: 26rpx;
 background-color: coral;
}

赋值

Page({
 data: {
 imgUrls: [
 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
 'http://img06.tooopen.com/images/20160818/tooopen_sy_1758634296.jpg',
 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
 ],
 currentSwiper: 0,
 autoplay: true
 },
 swiperChange: function (e) {
 this.setData({
 currentSwiper: e.detail.current
 })
 }
}) 

效果图:

总结

以上所述是小编给大家介绍的微信小程序修改swiper默认指示器样式的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

文档

微信小程序修改swiper默认指示器样式的实例代码

微信小程序修改swiper默认指示器样式的实例代码:修改官方swiper样式 从微信官方微信开发文档中心复制swiper 代码块。 wxml定义 <view class=wrap> <swiper class=swipers autoplay={{autoplay}} current={{currentSwiper}} bindchange=
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top