admin管理员组

文章数量:1130349

vue.js

在vue中获取dom元素的样式:

this.$refs.menuList.style.top;

这种获取方式是只能获取到元素的行内样式的。

this.$refs.menuList.getBoundingClientRect().top;

而下面这种方式是可以获取到外联样式表的样式的,不过这种是获取到计算过的样式。

let menuList = document.querySelector('.menuList');
let top = window.getComputedStyle(menuList).top;

这种方式获取到的是正常值。

转载于::

vue.js

在vue中获取dom元素的样式:

this.$refs.menuList.style.top;

这种获取方式是只能获取到元素的行内样式的。

this.$refs.menuList.getBoundingClientRect().top;

而下面这种方式是可以获取到外联样式表的样式的,不过这种是获取到计算过的样式。

let menuList = document.querySelector('.menuList');
let top = window.getComputedStyle(menuList).top;

这种方式获取到的是正常值。

转载于::

本文标签: vuejs