1. 安装
npm install--save better-scroll
2.引入(页面)
import BScroll from 'better-scroll'
3.template
1.子元素height > 父元素,才能滚动
2.父元素 height 固定(100%),overflow:hidden
3.父元素 ref
4.better-scroll只作用在第一个子元素上 class=‘wrapper’
<div class="home" ref="home">
<div class="wrapper">
<p>1.djjdgkfkjfdklv</p>
<p>2.djjdgkfkjfdklv</p>
...
<p>10.djjdgkfkjfdk</p>
<p>11.djjdgkfkjfdk</p>
</div>
</div>
4.初始化加载better-scroll
mounted/created中
mounted(){
this.$nextTick(()=>{
//获取更新后的dom值(this.$refs)
this.scroll = new BScroll(this.$refs.home,{
click:true
})
})
}