smoothscroll-polyfill 是什么?
它是一款纯JS页面的平滑滚动插件。该插件的特点是页面滚动的行为被作为window对象的扩展,用户可以通过window对象直接调用平滑滚动的方法。
smoothscroll-polyfill 什么使用?
1、安装插件
npm install smoothscroll-polyfill --save
2、在main.js中全局引入该插件
import smoothscroll from 'smoothscroll-polyfill';
smoothscroll.polyfill();
3、使用该插件
window.scroll({
top: scrollTop - 20,
left: 0,
behavior: "smooth", //滚动条平滑滚动
});