console
new Vue({
el: "#app",
data: {
styleObj: {
color: 'red'
},
bg: {
backgroundColor: 'blue',
color: '#fff'
}
},
computed: {
styleByComputed() {
return {
backgroundColor: 'orange',
color: '#fff'
}
}
},
methods: {
getColor() {
return `hsl(${Math.floor(Math.random() * 360)}, 75%, 85%)`
}
}
})
<div id="app">
<p :style="styleObj">set inline styel width data</p>
<p :style="styleByComputed">set inline style width computed</p>
<p :style="{color:'orange'}">set inline styel width object</p>
<p :style= "{color: 12 < 10 ? 'red' : 'yellow'}">set inline style width object base on condition</p>
<p :style="{color: getColor()}">set inline styel width object base on method</p>
<p :style="[bg,styleObj]">set inlne style with array</p>
<p :style="[12 > 10 ? bg : styleObj]">set inline style with array base on condition</p>
</div>