elementUI-table利用index给前三设置设置不同的

192 阅读1分钟

索引颜色设置

                      <el-table-column type="index" >
                        <template slot-scope="scope">
                          <span v-if="scope.$index+1 ==1" class="no1">{{scope.$index+1}}</span>
                          <span v-else-if="scope.$index+1 ==2" class="no2">{{scope.$index+1}} </span>
                          <span v-else-if="scope.$index+1 ==3" class="no3">{{scope.$index+1}} </span>
                          <span v-else class="no">{{scope.$index+1}} </span>
                        </template>
                      </el-table-column>

字段颜色设置

<el-table-column prop="number">
                        <template scope="scope">
                          <span v-if="scope.$index+1 ==1" class="no1">{{scope.row.number}} &nbsp;<span style="color:black ;">GB</span></span>
                          <span v-else-if="scope.$index+1 ==2" class="no2">{{scope.row.number}}&nbsp;<span style="color:black ;">GB</span> </span>
                          <span v-else-if="scope.$index+1 ==3" class="no3">{{scope.row.number}}&nbsp;<span style="color:black ;">GB</span></span>
                          <span v-else class="no">{{scope.row.number}}&nbsp;<span style="color:black ;">GB</span> </span>
                        </template>
                      </el-table-column>

样式设置(可以在此设置背景图片等,此处只设置了颜色)

  .no1 {
    color: blue;
  }
  .no2 {
    color: aqua;
  }
  .no3 {
    color: blueviolet;
  }