本文主要介绍vue选择框(vue滚动条位置),下面一起看看vue选择框(vue滚动条位置)相关资讯。
话不多说,直接代码供以后重用:
脚本类型= 文本/ecmascript-6 从导入b scroll ;更好的卷轴 ;const : { s: { typ:对象} },data{ r:[],listh:[],scrolly: 0 };}、comput: { current index{ for(设i = 0;i this . list height . length;i){ let height 1 = this . list height[i];设height 2 = this . list height[i 1];如果(!height 2 | |(this . scrolly = height 1 this . scrolly height 2)){ return i;};}返回0;} },已创建{ this . class map =[ ;减少 , 折扣 , 特殊和。;, 发票和发票。;, 担保与保险。;];这个。$ http . get( ;/api/ods ;).然后((response)= { response = response . body;if(response . errno = = = err _ ok){ this . ods = response . data;这个。$nexttick( = { this。_ init scroll;这个。_ calculat: { _ init scroll{ this . menus scroll = new b scroll(this。$refs.menuwrapper,{ click: true });this . food scroll = new b scroll(this。$r: 3 });this . food scroll . on( ;卷轴 ,(pos)= { this . scrolly = math . abs(math . round(pos . y));});},_ calculate height{ let food list = this。$ refs . foods wrapper . getelementsbyclassname( ;食物清单钩和。;);设高度= 0;this.listheight.push(高度);for(设i = 0;i foodlist.lengthi){ let item = food list[i];height = item.clientheightthis.listheight.push(高度);} },selectmenu(index,event) { if(!事件。_ constructed){ return;};console.log(索引);让foodlist = this。$ refs . foods wrapper . getelementsbyclassname( ;食物清单钩和。;);let el = food list[index];this . food scroll . scroll to element(el,300);} }};/script以上是边肖介绍的vue2.0中ods购物条滚动算法的实现代码。希望对你有帮助。如果您有任何问题,请给我留言,边肖将及时回复您。非常感谢您对网站的支持!
标签:
代码网站介绍希望
了解更多vue选择框(vue滚动条位置)相关内容请关注本站点。