I am using CSS Modules in my Vue application where a section of the template requires dynamic classes but having issues rendering the class in the $style object.
I have an internal data that toggles a boolean value.
data() {
return {
upper: false,
lower: false,
};
},
In the template below, I have this
<div
:class="[$style['class 1'], activeClass]">
</div>
Active class is computed as follows:
activeClass() {
return this.$style['active-class'] = this.upper;
}
There are methods that handles upper and lower based on the internal logic. Though these internal data values do return expected values but I can't seem to add the activeClass dynamically in the template.
base-class-[some-keybut when I need to add a modifier classactive-classbased on internal data, it does not render the modifier class. It has to do with how Vue's reactivity. - Mihir Patel