在我的html中:
<body onresize="doSomething();">
我的javascript中有这样的代码:
function doSomething() {
alert(1);
// it doesn't actually have alert(1), but this is just for demonstration
}
当我调整浏览器窗口的大小时(通过双击窗口标题),该事件在IE8中触发了两次,从而搞乱了函数。
提前感谢!
当我调整窗口大小的时候。下面的事件不是检测窗口大小,而是每次我得到的错误。
@HostListener('window:resize', ['$event'])
onResize(event) {
this.innerWidth = window.innerWidth;
}
错误:
GuidanceReportComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: jit_nodeValue_2(...).grElementList is not a function
at Object.
在我用盖茨比创建的网站上,我想在第一次呈现DOM window.innerWidth之前检查它的大小。我想用一个有条件的检查innerWidth来决定网站应该如何呈现:作为桌面或移动版本。一个简单的修复方法是在创建react组件之前检查窗口的宽度,并在代码中进一步使用true/false值。它在开发版本中有效,但是..。情况是,在生产版本中,当我进行gatsby构建时,控制台中出现了一个错误:
failed Building static HTML for pages - 2.872s
ERROR #95312
"window" is not available dur