vue 中使用better-scroll
1. 安装:yarn add better-scroll -S
2. 使用:
import BScroll from 'better-scroll';
// 请求到数据后
this.$nextTick(() => {
this.scroll = new BScroll(this.$refs.hot_body, { options });
)};
3. options
- 点击事件无效
options = {
click: true, // 开启click事件
}
- 滚动无法触发函数
optios = {
...
probeType: 1, // 监听滚动事件添加
}
4. 事件
- scroll
this.scroll.on('scroll', (pos)=>{
if( pos.y > 30){
this.pullDownMsg = '哼哧哼哧刷新中...';
}
});
- touchEnd
this.scroll.on('touchEnd', (pos)=>{
if( pos.y > 30){
this.pullDownMsg = '更新成功!';
}
});