// components/page-scroll/page-scroll.js Component({ /** * 组件的属性列表 */ properties: { "className":{ value:"", type:String }, "styleSheet":{ value:"", type:String }, "upper-threshold":{ value:5, type:Number }, "scrollitem":{ value:[], type:Array }, "scrollto":{ value:"", type:Number } }, /** * 组件的初始数据 */ data: { height:0, upper:true, index:0 }, ready:function(){ }, methods: { scrollLower:function(e){ this.triggerEvent("scrolltolower",e.detail); }, scrollUpper:function(e){ this.triggerEvent("scrolltoupper",e.detail); }, scroll:function(e){ var scrolltop = e.detail.scrollTop; var scrollitem =this.data.scrollitem; var index = 0; if(this.data.upper){ if(scrolltop>this.data["upper-threshold"]){ this.setData({ upper:false, height:0 }) } }else{ if(scrolltopscrollitem[l-1]){ index=l; }else{ for(var i=0;i