当前位置:网站首页>微信小程序轮播图怎么自定义光标位置
微信小程序轮播图怎么自定义光标位置
2022-06-24 18:50:00 【亿速云】
微信小程序轮播图怎么自定义光标位置
本篇内容介绍了“微信小程序轮播图怎么自定义光标位置”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
如图
轮播图的光标可以用定位来改变上下左右的位置
wxml:
<!--start banner --><swiper class='home-swiper' autoplay='true' bindchange='changDot' interval='4000'> <!-- 设置自动播放,切换间隔时间--> <swiper-item wx:for="{{slider}}" wx:for-index="index" wx:key="slider"> <image src='{{item.img}}'></image> </swiper-item></swiper><!-- 轮播图光标 --><view class="dots"> <block wx:for="{{slider}}" wx:key="slider"> <view class="dot {{index == swiperCurrent?'actives':''}}"></view> </block></view><!-- end banner -->
wxss:
/* 轮播图图片尺寸 */ .home-swiper { width: 100%; height: 350rpx; position: relative;} .home-swiper image { width: 100%; height: 100%;} /* 轮播图指示点 */ .dots { display: flex; flex-direction: row; position: absolute; top: 311rpx; width: 100%; height: 50rpx; justify-content: center;} .dots .dot { width: 20rpx; height: 20rpx; /* background-color: #333; */ /* border: 1rpx solid #e8672e; */ margin-left: 12rpx; background: #fff; border-radius: 20rpx; /* transform: all 0.6; */ opacity: 0.44;} /* 调用的css效果 */ .dots .actives { background-color: #fff; opacity: 1;}
js:
Page({ /** * 页面的初始数据 */ data: { swiperCurrent: 0, slider :[ {'img':'/img/img/1.jpg'}, { 'img': '/img/img/1.jpg' }, { 'img': '/img/img/1.jpg' }, { 'img': '/img/img/1.jpg' }, { 'img': '/img/img/1.jpg' } ] }, // 轮播图下标 changDot(e) { this.setData({ swiperCurrent: e.detail.current }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { }})
“微信小程序轮播图怎么自定义光标位置”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
边栏推荐
- JS deep understanding of scope
- 为什么生命科学企业都在陆续上云?
- 小滴课堂海量数据处理商用短链平台大课
- Use ado Net call stored procedure
- Value passing and reference passing of value types and reference types in CSharp
- 目前是不是只cdc 监控mysql 可以拿到新增列的数据 sqlserver不行是吧
- 通过SCCM SQL生成计算机上一次登录用户账户报告
- 696. count binary substring
- Freeswitch使用originate转dialplan
- How to perform power regression in R
猜你喜欢
随机推荐
JS deep understanding of functions
MySQL basic commands
Dataworks development ODPs SQL development production environment automatic completion of ProjectName
西北工业大学遭黑客攻击?双因素认证改变局面!
ArrayList源码解析
LabView之MQTT协议使用
UnityShader 世界坐标不随模型变化
Real time rendering: the difference between real-time, offline, cloud rendering and hybrid rendering
Differences between get and post request modes
JS picture display and hiding cases
干货 | 新手经常忽略的嵌入式基础知识点,你都掌握了吗?
[computer talk club] Lecture 3: how to raise key issues?
How do programmers do we media?
NFT pledge liquidity mining system development technology
Starring V6 platform development take out point process
Executing SQL statements with parameterized commands
Mqtt protocol usage of LabVIEW
Introduction, download and use of global meteorological data CRU ts from 1901 to 2020
《Go题库·11》channel的应用场景
初步学习Nuxt3