分享者:kingrome2017,来自原文一:带字母滑动的listviewwxml !--字母滑动-- view class= quot;letter-position quot; wx:if= quot;{{filterType == 'name'}} quot; hidden= quot;{{letterShow'true':''}} quot; style= quot;z-index:{{Zindex}} quot; 。。
分享者:kingrome2017,来自原文
一:带字母滑动的listview
wxml
lt;!--字母滑动-- gt; lt;view wx:if="{{filterType == 'name'}}" hidden="{{letterShow?'true':''}}" style="z-index:{{Zindex}}" catchtouchstart="handlerAlphaTap" catchtouchmove="handlerMove" catchtouchend="handlerEnd" gt;
lt;image data-loc="star" src="。/img/no-stars。png" gt; lt;/image gt;
lt;text wx:for="{{grouPHOTOSHOP}}" wx:for-item="group" data-loc="{{group。id}}" wx:key="L_{{group。id}}" gt;
{{group。id}}
lt;/text gt;
lt;text gt;
#
lt;/text gt; lt;/view gt;
lt;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 amp; amp; starCards。length ==0}}" gt;
js
handlerAlphaTap(e) {
var ap = e。target。dataset。loc; //字母
this。setData({
locationTo: ap
});
var list = this。data。grouPHOTOSHOP;
this。offsetTop = (this。data。clientHeihgt - list。length * 16) / 2; }, handlerMove(e) {
var _this = this;
var list = this。data。grouPHOTOSHOP;
var moveY = e。touches[0]。clientY;
var rY = moveY - this。宁波微信小程序开发其中,通过公众号关联,用户可以实现公众号与小程序之间相互跳转。小程序体现了“用完即走”的理念,用户不用关心是否安装太多应用的问题。应用将无处不在,随时可用,但又无需安装卸载。 offsetTop;
if (rY gt;= 0) {
var index = Math。ceil((rY - 16) / 16);
if (0 lt;= index amp; amp; index lt; 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
}); },二:js回调函数
回调函数原理:
我现在出发,到了通知你”
这是一个异步的流程,“我出发”这个过程中(函数执行),“你”可以去做任何事,“到了”(函数执行完毕)“通知你”(回调)进行之后的流程