better-scroll第一次使用

官方文档 https://github.com/ustbhuangyi/better-scroll/blob/master/README_zh-CN.md

安装

控制台输入 npm install better-scroll --save

引入 import BScroll from 'better-scroll'

html结构:必须要有一个wrapper,下面内容放在一个div里

<div class="wrapper">
  <ul class="content">
    <li>...</li>
    <li>...</li>
    ...
  </ul>
  <!-- 这里可以放一些其它的 DOM,但不会影响滚动 -->
</div>->

例子:在mounted函数上创建一个新的实例

import BScroll from 'better-scroll'
export default {
  name: 'CityList',
  mounted () {
    this.scroll = new BScroll(this.$refs.wrapper)
  },

 

posted on 2018-08-14 10:14  想养猫的通信狗  阅读(312)  评论(0编辑  收藏  举报