gpt4 book ai didi

JavaScript - window.scroll({ 行为 : 'smooth' }) not working in Safari

转载 作者:行者123 更新时间:2023-12-04 11:46:07 26 4
gpt4 key购买 nike

正如标题所说,它在 Chrome 上运行良好。但在 Safari 中,它只是将页面设置到所需的顶部和左侧位置。这是预期的行为吗?有没有办法让它很好地工作?

最佳答案

使用 smootscroll polyfill (适用于所有浏览器的解决方案),易于应用和轻量级的依赖:
https://github.com/iamdustan/smoothscroll

通过 npm 或 yarn 安装后,将其添加到您的 .js, .ts 文件(第一个执行的文件)

import smoothscroll from 'smoothscroll-polyfill';
// or if linting/typescript complains
import * as smoothscroll from 'smoothscroll-polyfill';

// kick off the polyfill!
smoothscroll.polyfill();

关于JavaScript - window.scroll({ 行为 : 'smooth' }) not working in Safari,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54530659/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com