github上面搜索 better-scroll
安装better-scroll : npm i better-scroll --save
使用条件:
1、html结构
<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>
解释:必须外层套一个div.里面也必须是一个块级结构div或者ul等
2、具体使用
import BScroll from 'better-scroll'
const wrapper = document.querySelector('.wrapper')
const scroll = new BScroll(wrapper)//方法一
import BScroll from 'better-scroll'
const scroll = new BScroll('.wrapper')//方法二
在去哪儿项目中具体使用:
html结构操作,ref="wrapper"获取dom
引入