Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline Styles Not Working in VueJS

I've been following the guide: https://vuejs.org/v2/guide/class-and-style.html#Binding-Inline-Styles for inline css in VueJS. However in some situations, it not working.

:style="{ background: colorSelected }" // working

The following gives an error saying: - invalid expression: :style="{ border-color-left: colorSelected }"

:style="{ border-color-left: colorSelected }" // not working

like image 213
Gijo Varghese Avatar asked Jul 14 '17 11:07

Gijo Varghese


1 Answers

It's invalid JavaScript syntax for an object literal. The object property needs to have quotes:

:style="{ 'border-left-color': colorSelected }"

or you can specify it like this (Vue-specific):

:style="{ borderLeftColor: colorSelected }"

Also the style is border-left-color not border-color-left.

like image 122
Decade Moon Avatar answered Nov 09 '22 02:11

Decade Moon