javascript - How does vue get the page element style to be empty?
大家讲道理
大家讲道理 2017-06-26 10:52:51
0
3
929

After obtaining the html element object, how to solve the problem that all its output styles are empty?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
阿神

You can use $el instead of $ref to get the root DOM element of the current component.
If canvas is involved, you need to pay attention not to get the style from the context object of the canvas, but to get the style from the DOM element corresponding to the canvas.

洪涛

Try window.getComputedStyle(document.documentElement)

学霸

You need to write like this to get the external style. You can only get the inline style

let style = window.getComputedStyle(element, [pseudoElt]);
element
Used to get the Element of the calculated style
pseudoElt Optional
Specify a string of pseudo elements to match. Must be omitted (or null) for ordinary elements.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template