したがって、角度2でIDによってオフセットされた要素を取得する方法はありますか?角度2のgetBoundingClientRect()からオブジェクトが 'null'になる可能性があります
このDo'n:
scrollToBottom() { let content = document.getElementById('content') let offsetTop = content.getBoundingClientRect().top console.log(content, offsetTop) }
が、私はこのエラーを取得:助けをObject is possibly 'null'.
Thxを。
こちらをご覧ください:https://stackoverflow.com/questions/40349987/how-to-suppress-typescript-error-ts2533-object-is-possibly-null-or-undefine#40350534 – Catalyst