Reputation: 5791
I can bind a class to an element in vue
depending on a condition like so:
:class="i18n.global.locale == 'ar' ? 'class1': 'class2'"
but when I try to bind a style
with the same condition like so:
:style="[i18n.global.locale == 'ar' ? { 'background': 'blue;' }: { 'background': 'red' } ]"
neither of the styles
is applied to the element. Why is the :style
directive not working?
Both directives are applied to the container div
which envelopes all other elements.
Upvotes: 0
Views: 80
Reputation: 113
I made some research for your issue, so to resolve it you may do:
{ 'background': 'blue;' }
try to delete ';', as for me it started works when i deleted.Upvotes: 2