在vue中获取dom元素的样式:
this.$refs.menuList.style.top;
这种获取方式是只能获取到元素的行内样式的。
this.$refs.menuList.getBoundingClientRect().top;
而下面这种方式是可以获取到外联样式表的样式的,不过这种是获取到计算过的样式。
let menuList = document.querySelector('.menuList');
let top = window.getComputedStyle(menuList).top;
这种方式获取到的是正常值。