better-scroll 在vue 中的使用

下载

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 ()
   })
}

猜你喜欢

转载自blog.csdn.net/qq_38992657/article/details/82692304