这篇文章主要介绍微信小程序如何实现listview带字母滑动,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
微信小程序 实现listview带字母滑动
wxml
<!--字母滑动--> <view class="letter-position" wx:if="{{filterType == 'name'}}" hidden="{{letterShow?'true':''}}" catchtouchstart="handlerAlphaTap" catchtouchmove="handlerMove" catchtouchend="handlerEnd"> <image class="no-stars star-icon" data-loc="star" src="../img/no-stars.png"></image> <text class="letter" wx:for="{{groups}}" wx:for-item="group" data-loc="{{group.id}}" wx:key="L_{{group.id}}"> {{group.id}} </text> <text class="letter no-letter"> # </text> </view>
<scroll-view scroll-into-view="{{locationTo}}" bindscrolltolower="onscrollLower" scroll-y="{{trues}}" bindscroll="scroll" scroll-top="{{scrollTop}}" hidden="{{favoriteCards.length==0 && starCards.length ==0}}">
js
handlerAlphaTap(e) { var ap = e.target.dataset.loc; //字母 this.setData({ locationTo: ap }); var list = this.data.groups; this.offsetTop = (this.data.clientHeihgt - list.length * 16) / 2; }, handlerMove(e) { var _this = this; var list = this.data.groups; var moveY = e.touches[0].clientY; var rY = moveY - this.offsetTop; if (rY >= 0) { var index = Math.ceil((rY - 16) / 16); if (0 <= index && index < list.length) { _this.setData({ locationTo: list[index].id, nonwApID: list[index].id, fly: false, //nonwAp: list[index] }); // _this.setData({ // nonwApID:_this.data.nonwAp.id // }); } } }, handlerEnd(e) { // try{ this.setData({ nonwApID: '', fly: true, // locationTo:this.data.nonwAp.id }); // }catch(e){ // } var _this = this; this.setData({ scoTTTTp: e.currentTarget.dataset.scrollTop }); },
以上是“微信小程序如何实现listview带字母滑动”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联网站建设公司行业资讯频道!
另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
本文名称:微信小程序如何实现listview带字母滑动-创新互联
新闻来源:https://www.cdcxhl.com/article36/cocisg.html
成都网站建设公司_创新互联,为您提供微信小程序、网站内链、营销型网站建设、关键词优化、网站设计、微信公众号
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联