element-ui 表格的行數的某個值按照介面傳的不同值顯示不同的顏色
阿新 • • 發佈:2018-11-08
<el-table :data="affairtypes" highlight-current-row v-loading="listLoading" @selection-change="selsChange" @sort-change="sortChange" style="width: 100%;">
<el-table-column prop="isvisible" label="顯示" :formatter="formatVisible" width="100" sortable></el-table-column>
<template slot-scope="scope" >
<div :style="{'color':scope.row.isvisible=='1'?'red':'#333'}">{{scope.row.isvisible}}{{scope.row.isvisible=='1'?'red':'#333'}} </div>
</template>
</el-table-column>
</el-table>
本來不考慮顏色直接就是去掉紅色的部分,現在表格的內容不通過prop顯示而是下面的template的內容顯示。這樣你就可以在div里加樣式了