vue 判断数字是否在某个区间,请使用逻辑判断符 &&

<el-table :data="tableData" border>
     <el-table-column
         prop="overlimit"
         label="超标幅度">
         <template slot-scope="scope">
              <span>
                      <!-- 区间:[0, 0.5) -->
                      <span v-if="0<=(scope.row.overlimit-0) && (scope.row.overlimit-0)<0.5" class="firstLimit" >{{scope.row.overlimit}}</span>

                      <!-- 区间:[0.5, 1) -->
                      <span v-else-if="0.5<=(scope.row.overlimit-0) && (scope.row.overlimit-0)<1" class="secondLimit" >{{scope.row.overlimit}}</span>

                      <!-- 区间:[1, +∞) -->
                      <span v-else-if="(scope.row.overlimit-0)>=1"  class="thirdLimit">{{scope.row.overlimit}}</span>
                    </span>
              </span>
         </template>
     </el-table-column>
</el-table>

效果如下:

Logo

前往低代码交流专区

更多推荐