Set in style:
<view class="box" :style="{background:color}"> </view>
data() {
return {
color:'blue'
};
},
set in class
<view class="box" :class="{myStyle:state}">
</view>
<view class="box" :class="state?'myStyle':''">
</view>
data() {
return {
state:true
};
},
<style lang="scss">
.myStyle{
background-color: $uni-bg-color-grey;
}
</style>