非常感谢,不过有一些bug
// Thank you very much, but there are some bugs
这个代码在直接调用window.scrollTo函数的时候可能导致栈溢出:
// This code may cause a stack overflow when calling the window.scrollTo function directly:
// Disable the scroll to top functionality
function disableScrollToTop() {
window.scrollTo = function(x, y) {
if (y !== 0) {
window.scrollTo.originalFunc(x, y);
}
};
window.scrollTo.originalFunc = window.scrollTo;
}
可以用下面的代码替换:
// Can be replaced with the following code:
// Disable the scroll to top functionality
function disableScrollToTop() {
let originalFunc = window.scrollTo;
window.scrollTo = function(x, y) {
if (y !== 0) {
originalFunc(x, y);
}
};
}
非常感谢,不过有一些bug
// Thank you very much, but there are some bugs
这个代码在直接调用
window.scrollTo
函数的时候可能导致栈溢出:// This code may cause a stack overflow when calling the
window.scrollTo
function directly:可以用下面的代码替换:
// Can be replaced with the following code: