javascript - scrollTo(target, options) 在移动设备中不起作用。(机车卷轴)
问题描述
我面临一个奇怪的问题。在桌面上,一切正常,但是当我切换到移动设备时,发生了一些奇怪的事情,不知道为什么。scrollTo(target, options) 根本不起作用。在桌面水平模式上,对于移动设备,我已将其关闭,并且在移动设备上也关闭了平滑。
我的代码:
const lscroll = new LocomotiveScroll({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
repeat: false,
getDirection: true,
direction: 'horizontal',
tablet: {
smooth: false,
direction: "vertical"
},
smartphone: {
smooth: false,
direction: "vertical"
},
});
我也尝试过使用平滑真实的移动设备,但没有发生任何事情。请帮我解决一下这个。TIA
解决方案
像这样在html文件中使用它
<a href="#here" data-scroll-to>
scroll to explore
</a>
..
..
<section id="here">`enter code here` </section>
如果机车滚动在 JS 中正确初始化,它应该可以工作
推荐阅读
- macos - 离线时在带有 .net 核心的 docker 构建中使用 nuget 缓存
- c++ - 如何在这种情况下应用 C++ 标准算法?
- machine-learning - 如何根据内容对与圣经相关的文本进行分类
- r-leaflet - R-Leaflet Map - 帮助我在 R 传单中结合 2 个图例
- node.js - Angular ssr 清漆使用
- function - 是否可以在 PowerShell 函数中自动传递开关参数?
- html - 如何在闪亮的应用程序中包含 html/css
- python - 重命名文件并使用 Python 将其存储到 csv
- c# - C# - 类型检查接口
- javascript - 正文解析器不适用于打字稿,当我发送请求时,我在 request.body 中得到未定义