想问一下,为什么获取不到 style.left 的值?但在执行 this.st?

想问一下,为什么获取不到 style.left 的值? 但在执行 this.st?

fbaf1b4f544c5ebfc15a8e058b1567e5.png
65a1957c54cb37d33cfa793c1d63f30d.png

请先 登录 后评论

1 个回答

xxxxxa

因为this.style.left只能读取行间样式的值,你设置之后就是设置了行间样式,要想读取style标签里面的样式,你可以用window.getComputedStyle,https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle

请先 登录 后评论