解决better-scroll在Vue动态渲染数据后不能滚动问题

239 阅读1分钟

解决better-scroll在Vue动态渲染数据后不能滚动问题

better-scroll官网 github.com/ustbhuangyi…

通过npm安装

npm install better-scroll --save

页面引入

import BScroll from 'better-scroll'

页面结构

<div class="wrapper">
  <ul class="content">
    <li>...</li>
    <li>...</li>
    ...
  </ul>
  <!-- you can put some other DOMs here, it won't affect the scrolling
</div>
mounted() {
    this.scroll = new BScroll(this.$refs.wrapper)
},
updated() {
    // 解决better-scroll在Vue动态渲染数据后不能滚动问题
    this.scroll && this.scroll.refresh();
}