您现在的位置是:网站首页> 编程资料编程资料
微信小程序swiper轮播图组件使用方法详解_javascript技巧_
2023-05-24
312人已围观
简介 微信小程序swiper轮播图组件使用方法详解_javascript技巧_
本文实例为大家分享了微信小程序swiper轮播图组件的使用,供大家参考,具体内容如下
在components中新建文件夹swiper
components/swiper/swiper.wxml
components/swiper/swiper.js
Component({ properties: { swiperList: { type: Array, value: []// 默认数据(可以从引用组件处的属性传入该属性值) } }, data: { currentIndex: 0 // 初始高亮下标 }, methods: { /* 这里实现控制自定义轮播指示点高亮 */ swiperChange(e) { this.setData({ currentIndex: e.detail.current }) } } })components/swiper/swiper.wxss
/* components/swiper/swiper.wxss */ .container { position: relative; } .swiper-box { width: 100%; height: 364rpx; } .targetImg { width: 100%; height: 100%; } /*小圆点 */ .dots { width: 100%; height: 4rpx; display: flex; position: absolute; bottom: 30rpx; } .dotsBox { height: 4rpx; display: flex; margin: 0 auto; } /*未选中时的小圆点样式 */ .dot { width: 26rpx; height: 4rpx; border-radius: 2rpx; margin-right: 10rpx; background-color: #ffffff; opacity: 0.4; } /*选中以后的小圆点样式 */ .dot-active { opacity: 1; }在pages文件中引用
json文件中
{ "usingComponents": { "w-swiper":"/components/swiper/swiper" } }html文件中
js文件中
data:{ sprList:['/images/img.png','/images/img.png'], }以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
您可能感兴趣的文章:
相关内容
- Vue3插槽Slot实现原理详解_vue.js_
- 微信小程序实现播放音频功能_javascript技巧_
- Vue3生命周期Hooks原理与调度器Scheduler关系_vue.js_
- React Diff算法不采用Vue的双端对比原因详解_vue.js_
- TypeScript 接口继承的具体使用_javascript技巧_
- 微信小程序实现弹出框提交信息_javascript技巧_
- Vue3 计算属性的用法详解_vue.js_
- 微信小程序实现弹出层禁止页面滚动_javascript技巧_
- vue+elementUI实现分页效果_vue.js_
- 微信小程序canvas实现手写签名_javascript技巧_
