mounted() {
this.scroll = new BScroll(this.$refs.wrapper, {
probeType: this.probeType,
pullUpLoad: this.pullUpLoad,
click: true
}),
this.scroll.on('pullingUp', () => {
this.$emit('pullingUp')
}),
this.scroll.on('scroll', (position) => {
this.$emit('scrolling', position)
})
},
methods: {
scrollTo(x, y, time = 500) {
this.scroll.scrollTo(x, y, time)
},
finishPullUp() {
this.scroll.finishPullUp()
}
如果在mounted之前回调scroll的方法时,会显示scroll为undefined,这时最好在判断this.scroll是否存在再执行
methods: {
scrollTo(x, y, time = 500) {
this.scroll && this.scroll.scrollTo(x, y, time)
},
finishPullUp() {
this.scroll && this.scroll.finishPullUp()
}