supermall項目---better-scroll的應(yīng)用
先安裝better-scroll,自行百度
第一步創(chuàng)建scroll組件,并在data中設(shè)立scroll對象為null
第二步在mounted(所有元素掛載完成后),將better-scroll實例賦給scroll
new BScroll(指定對象,{屬性值})
?this.scroll=new?BScroll(this.$refs.wrapper,{
??????click:true,//允許內(nèi)部點擊事件
??????observeDOM?:true,//解決滑動或刷新導(dǎo)致滾動條失效
??????probetype:this.probetype,//根據(jù)級別,判定是否監(jiān)聽position
??????pullUpLoad:this.pullUpload//設(shè)立上拉加載功能,當(dāng)為true時開啟
????})
第三步在mounted中,設(shè)置觸發(fā)條件,觸發(fā)事件,和動機
if(條件)this.scroll.on('要監(jiān)聽的事件',()=>{
? 動機
})
對于bs,不同的監(jiān)聽事件,攜帶的默認(rèn)參數(shù)不同
if(this.probetype==2||this.probetype==3){
??????this.scroll.on('scroll',(position)=>{
??????this.$emit('showposition',position)
??????this.$emit('showdetailposition',position)
????})
????}
????if(this.pullUpload){
??????this.scroll.on('pullingUp',()=>{
??????this.$emit('pullingUp')
????})
????}