在vue2.0商品购物列滚动算法的实现代码

在vue2.0商品购物列滚动算法的实现代码
不太多,直接代码,以便它可以在未来重复使用。
进口bscroll from'better-scroll;
const err_ok = 0;
出口默认{
道具:{
销售:{
类型:对象
}
},
数据(){
返回{
Ods:{ },
该:{ },
scrolly:0
};
},
计算机:{
currentindex(){
为了(让我= 0;i < this.listheight.length;i++){
让height1 =这该{我};
让身高2 =这。该{我+ 1 };
如果(身高2 | |!(this.scrolly this.scrolly < height1 > =身高2){)
还我;
};
}
返回0;
}
},
创建(){
this.classmap = { 'decrease ','discount ',特别的,'invoice ','guarantee};
这http.get美元( / / ODS API)。然后((响应)= > {
response.body响应=;
如果(response.errno = err_ok){
this.ods = response.data;
((这nexttick美元)= > {
这_initscroll();
这_calculateheight();
});
}
});
},
方法:{
_initscroll(){
this.menuscroll =新bscroll(这refs.menuwrapper美元,{。
点击:真实
});
this.foodscroll =新bscroll(这refs.foodswrapper美元,{。
probetype:3
});
This.foodScroll.on('scroll(POS)= > {
this.scrolly = math.abs(math.round(pos.y));
});
},
_calculateheight(){
让foodlist =这refs.foodswrapper.getelementsbyclassname美元('food-list-hook);
让高度= 0;
This.listHeight.push(高度);
为了(让我= 0;i < foodlist.length;i++){
让项目组foodlist {我};
高度= item.clientheight;
This.listHeight.push(高度);
}
},
SelectMenu(索引、事件){
如果(!事件。_constructed){
返回;
};
console.log(指数);
让foodlist =这refs.foodswrapper.getelementsbyclassname美元('food-list-hook);
让EL = foodlist {指数};
this.foodscroll.scrolltoelement(EL,300);
}
}
};
以上是ODS柱在购物vue2.0滚动算法的实现代码,我想帮你。如果你有任何问题,请给我留言,萧边会及时给您回复。谢谢您支持网站。

tag:商品算法代码电脑软件

相关内容