Answer the question
In order to leave comments, you need to log in
How to optimize style code in Vue template?
I use Vue with vue-loader - I like everything, but I don’t like the conditional style syntax used by me in the template (mega-poor), tell me how can this be done more elegantly?
<app-input type="button" v-on:click="currentLayout = false"
:class="{ [$style.layout_switcher__grid]: true, [$style.__active]: !currentLayout }" >
<span :class="$style.grid__icon"></span>
</app-input>
<app-input type="button" v-on:click="currentLayout = true"
:class="{ [$style.layout_switcher__list]: true, [$style.__active]: currentLayout }">
<span :class="$style.list__icon"></span>
</app-input>
:class="{ [$style.layout_switcher__grid]: true, [$style.__active]: currentLayout }"
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