better-scroll 在vue 中的使用
阿新 • • 發佈:2018-12-05
下載
npm install –save-dev better-scroll
使用方法
html
<div class='big_out' ref='bigout'>
<ul>
<li v-for='(n, index) in 10' :key='n'></li>
</ul>
</div>
css
.big_out{
height: 100px;
backgroung-color: red;
}
.big_out ul li{
height: 30px;
background-color : blue;
}
非非同步獲取時的vue程式碼
import BScroll from 'better-scroll';
mounted () {
_initBScroll: function () {
this.main = new BScroll (this.$refs.bigout, {
click: true,
scrollY: true
})
}
},
mounted () {
this.$nextTick( () = > {
this._initBScroll ()
})
}