window.onresize(シングルページアプリケーション)を購読している場合、メモリリークを避けるために購読を解除する必要がありますか?もしそうなら、どうしたらいいですか?退会するにはwindow.onresizeイベントを破棄するサブスクライバ
<script type="text/javascript">
var heightOutput = document.querySelector('#height');
var widthOutput = document.querySelector('#width');
function resize() {
heightOutput.textContent = window.innerHeight;
widthOutput.textContent = window.innerWidth;
}
window.onresize = resize;
</script>
https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onresize
* window.onresize = null *私のためには機能しませんでした! – coderz
それはうまくいく、あなたが加入者を付けた方法に依存する。 'addEventListener'やjQueryの' .resize'を使った場合、 'onresize = null'は動作しません。 – user3297291