Answer the question
In order to leave comments, you need to log in
Get css property of vue element?
Good day, tell me how to get the css property of an element on vue js
for example
<div id="test"></div>
<style>
#test{
color:red
}
</style>
Answer the question
In order to leave comments, you need to log in
The easiest option is inline-style
activeColor - from props or from data
That is, you don't need to get anything, you just need to set it.
The part of the CSS that will somehow change should be built based on the data initially. And then you get these CSS properties not directly from css, but from the data based on which the CSS properties are updated
The question is wrong. Reactivity lies in the fact that you do not "pick up" changes, but associate some kind of state (in this case, the value of the color css property) with the reactive Vue model (data, props, computed). And you work with the model, not with the styles. As you actually answered above.
https://ru.vuejs.org/v2/api/#ref
https://developer.mozilla.org/ru/docs/Web/API/Wind...
This is enough
You can get it this way, BUT in your case this approach is wrong
let element = document.getElementById("red-block") // #red-block { background: red }
let style = window.getComputedStyle(element)
console.log(style.getPropertyValue("background-color")) // rgb(255,0,0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question