:style :class

2.1、html代码

  1. <div id="app">
  2.  <!--整个数组-->
  3.  <div v-bind:style="[baseStyles, overridingStyles]">{{[baseStyles, overridingStyles]}}</div>
  4.  <!--数组+三元表达式-->
  5.  <div v-bind:style="[{backgroundColor:isActive ? '#f00' : '#00f'},baseStyles]">如果isActive==true,背景红色</div>
  6.  <!--对象+数组-->
  7.  <div v-bind:style="[{ baseStyles: Active }, overridingStyles]">{{[{ baseStyles: Active }, overridingStyles]}}</div>
  8. </div>

<span :class="{'fonts':ruleForm.BMI=='请完善身高体重'}">{{ruleForm.BMI}}</span>
<!--<span :style="{color:ruleForm.BMI=='请完善身高体重' ? 'red' : blue}">{{ruleForm.BMI}}</span>-->

posted @ 2018-01-02 16:11  小牧临风  阅读(101)  评论(0编辑  收藏  举报