search

Home  >  Q&A  >  body text

javascript - How does vue get the page element style to be empty?

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

大家讲道理大家讲道理2766 days ago980

reply all(3)I'll reply

  • 阿神

    阿神2017-06-26 10:54:51

    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.

    reply
    0
  • PHP中文网

    PHP中文网2017-06-26 10:54:51

    Try window.getComputedStyle(document.documentElement)

    reply
    0
  • 欧阳克

    欧阳克2017-06-26 10:54:51

    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.

    reply
    0
  • Cancelreply