Answer the question
In order to leave comments, you need to log in
Pass value of js variable to css without inheritance?
Hello, when in vue 3 we want to pass the value of the js variable to css, we use for example
data() {
return {
var:"red",
}
}
background: v-bind(var)
style attribute {
--b6cbff56-var: red;
}
directives: {
var: {
mounted(el) {
el.style.setProperty("--var", "red");
},
},
},
so that the id is delivered to the variable name and that it can be obtained, for example, v-bind:mydir(var); Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question