ts Property ‘offsetTop’ does not exist on type ‘Element’
problem
ts Property ‘offsetTop’ does not exist on type ‘Element’
reason
There is no offsetTop on the Element type, and there is an offsetTop on the HTMLElement type, which
can be viewed by clicking on the type
solution
// 修改前
const element = document.getElementById('my-element') as Element;
const offsetTop = element.offsetTop;
// 修改后
const element = document.getElementById('my-element') as HTMLElement;
const offsetTop = element.offsetTop;