0👍
you might want to use a single computed property for all styles of this element. for example:
elementStyle(){
const style = {}
if(condition1){
style['background-color'] = backgroundColorValue
}
if(condition2){
style['color'] = colorValue
}
if(condition3){
style['border-bottom'] = borderBottomValue
}
....
return style
}
and in the template just do
:style="elementStyle"
- [Vuejs]-How to select specific information in a specific object from an array of objects using Vue.js?
- [Vuejs]-Laravel / Vue : unable to load vue component in blade tmeplate
0👍
In template
:style="styles"
In script
computed: {
styles() {
return isInCheckout
? { backgroundColor: bgColor, color: fColor, borderBottom: '2px' }
: { 'background-color': bgColor, color: fColor }
}
}
Source:stackexchange.com