![](/img/trans.png)
[英]How do I get the current page name if it's not displayed in the URL when that page is the default page for a web app?
[英]How do I get the scrolling element of current web page?
如果路线发生变化,我想在我移动的页面上找到带有滚动条的元素并给它window.scrollTo(0,0),我应该如何找到该元素?
当前代码
if (process.client) {
router.afterEach((to, from) => {
document.querySelector('.overflow-scroll').scrollTo(0, 0)
})
}
代码运行良好,但我不想使用 document.querySelector。 我想在路由时找到滚动元素!
使事件监听器和事件监听器中的参数“滚动”编写预定义的函数或关键字,就像scrollX或scrollY您也可以使用bottom 或top。
scroller.addEventListener("scroll", event => {
output.textContent = `scrollBy: ${scroller.scrollBy}`;
});
这是滚动是要滚动的 html 类和 Id html 元素。 输出只是显示多少像素,你滚动它他是 **html 类或 Id ** 你可以删除它。
深入了解或学习。
https://www.w3.org/TR/2016/WD-cssom-view-1-20160317/#dom-element-scrolltop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.