网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序帶字母滑動的listview, js中回調函數

發布時間:2018-04-18 10:46 所屬欄目:小程序開發教程

分享者:kingrome2017,來自原文地址

 

一:帶字母滑動的listview

wxml

 

				
  1. <!--字母滑動-->
  2. <view class="letter-position" wx:if="{{filterType == 'name'}}" hidden="{{letterShow?'true':''}}" style="z-index:{{Zindex}}" catchtouchstart="handlerAlphaTap" catchtouchmove="handlerMove" catchtouchend="handlerEnd">
  3. <image class="no-stars star-icon" data-loc="star" src="../img/no-stars.png"></image>
  4. <text class="letter" wx:for="{{groups}}" wx:for-item="group" data-loc="{{group.id}}" wx:key="L_{{group.id}}">
  5. {{group.id}}
  6. </text>
  7. <text class="letter no-letter">
  8. #
  9. </text>
  10. </view>
 

				
  1. <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

 

				
  1. handlerAlphaTap(e) {
  2. var ap = e.target.dataset.loc; //字母
  3. this.setData({
  4. locationTo: ap
  5. });
  6.  
  7. var list = this.data.groups;
  8. this.offsetTop = (this.data.clientHeihgt - list.length * 16) / 2;
  9.  
  10. },
  11.  
  12. handlerMove(e) {
  13. var _this = this;
  14. var list = this.data.groups;
  15. var moveY = e.touches[0].clientY;
  16. var rY = moveY - this.offsetTop;
  17. if (rY >= 0) {
  18. var index = Math.ceil((rY - 16) / 16);
  19. if (0 <= index && index < list.length) {
  20. _this.setData({
  21. locationTo: list[index].id,
  22. nonwApID: list[index].id,
  23. fly: false,
  24. //nonwAp: list[index]
  25. });
  26. // _this.setData({
  27. // nonwApID:_this.data.nonwAp.id
  28. // });
  29. }
  30.  
  31. }
  32. },
  33. handlerEnd(e) {
  34. // try{
  35. this.setData({
  36. nonwApID: '',
  37. fly: true,
  38. // locationTo:this.data.nonwAp.id
  39. });
  40. // }catch(e){
  41.  
  42. // }
  43. var _this = this;
  44. this.setData({
  45. scoTTTTp: e.currentTarget.dataset.scrollTop
  46. });
  47.  
  48. },
 

二:js回調函數

回調函數原理:

我現在出發,到了通知你”  這是一個異步的流程,“我出發”這個過程中(函數執行),“你”可以去做任何事,“到了”(函數執行完畢)“通知你”(回調)進行之后的流程

點擊此處轉載參考文獻



易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23673.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×