安裝:
npm install better-scroll --save
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>
引入及使用:
import BScroll from '@better-scroll/core' //引用 let wrapper = document.querySelector('.wrapper') //獲取dom let scroll = new BScroll(wrapper) //創建實例