小程序 listview 微信小程序 实现listview带字母滑动

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

小程序 listview 微信小程序 实现listview带字母滑动

kingrome2017   2021-03-24 我要评论
想了解微信小程序 实现listview带字母滑动的相关内容吗,kingrome2017在本文为您仔细讲解小程序 listview的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:微信小程序带字母滑动的listview,小程序,listview,滑动,下面大家一起来学习吧。

微信小程序 实现listview带字母滑动

wxml

 <!--字母滑动-->
 <view class="letter-position" wx:if="{{filterType == 'name'}}" hidden="{{letterShow?'true':''}}" style="z-index:{{Zindex}}" 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}}" style="height: {{clientHeihgt?clientHeihgt+'px':'auto'}}" 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
  });

 },

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们