如果是移动端项目,阻止 touchmove 事件的默认行为可以防止滚动;如果是桌面端项目,
可以让根元素直接 overflow:hidden。
windows:
在蒙层显示的同时执行下面的 JavaScript 代码:
var widthBar = 17, root = document.documentElement;
if (typeof window.innerWidth == 'number') {
widthBar = window.innerWidth - root.clientWidth;
}
root.style.overflow = 'hidden';
root.style.borderRight = widthBar + 'px solid transparent';
var widthBar = 17, root = document.documentElement;
if (typeof window.innerWidth == 'number') {
widthBar = window.innerWidth - root.clientWidth;
}
root.style.overflow = 'hidden';
root.style.borderRight = widthBar + 'px solid transparent';
var root = document.documentElement;
root.style.overflow = '';
root.style.borderRight = '';