Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
An observer is hung on the property of the component that updates the css variable. For example :
#app h1 {
font-size: var(--h1-font-size);
}
<div id="app" ref="app">
<input v-model="fontSize" type="number">
<h1>hello, world!!</h1>
</div>
data: () => ({
fontSize: 24,
}),
mounted() {
this.$watch(
'fontSize',
val => this.$refs.app.style.setProperty('--h1-font-size', `${val}px`),
{
immediate: true,
}
);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question