ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

({behavior: smooth}) 在移动端不生效的问题解决 ios不平滑,使用smoothscroll-polyfill(页面平滑滚动)插件

({behavior: smooth}) 在移动端不生效的问题解决 ios不平滑,使用smoothscroll-polyfill(页面平滑滚动)插件

smoothscroll-polyfill 是什么?

它是一款纯JS页面的平滑滚动插件。该插件的特点是页面滚动的行为被作为window对象的扩展,用户可以通过window对象直接调用平滑滚动的方法。

 

官方介绍及Demo

GitHub源码地址

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", //滚动条平滑滚动});

 

返回列表