滚动插件bette-scroll的使用记录

文档链接 :https://blog.csdn.net/weixin_43487066/article/details/105409599

安装 npm install better-scroll -S

组件  scroll.vue

<template>
  <div ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
import BScroll from 'better-scroll'
export default {
  data () {
    return {
      scroll: null
    }
  },
  // 组件创建完后调用。
  mounted () {
    this.scroll = new BScroll(this.$refs.wrapper,{
      click:true
      
    })
  }

}
</script>

使用

import Scroll from './scroll'


 <Scroll class="contents" ref="Scroll">
</Scroll>


.contents{
    position: relative;
    height:500px;
    overflow: hidden;
    left: 0;
}
原文地址:https://www.cnblogs.com/wangshengli520/p/14959306.html