欢迎光临散文网 会员登陆 & 注册

supermall项目---better-scroll的应用

2022-03-08 22:55 作者:忘魂儿  | 我要投稿

先安装better-scroll,自行百度

第一步创建scroll组件,并在data中设立scroll对象为null

第二步在mounted(所有元素挂载完成后),将better-scroll实例赋给scroll

new BScroll(指定对象,{属性值})

 this.scroll=new BScroll(this.$refs.wrapper,{

      click:true,//允许内部点击事件

      observeDOM :true,//解决滑动或刷新导致滚动条失效

      probetype:this.probetype,//根据级别,判定是否监听position

      pullUpLoad:this.pullUpload//设立上拉加载功能,当为true时开启

    })

第三步在mounted中,设置触发条件,触发事件,和动机

if(条件)this.scroll.on('要监听的事件',()=>{

  动机

})

对于bs,不同的监听事件,携带的默认参数不同

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')

    })

    }


supermall项目---better-scroll的应用的评论 (共 条)

分享到微博请遵守国家法律