<el-table-column label="type" width="200">
<template #default="scope">
<div v-if="scope.row.style">在线</div>
<div v-else>离线</div>
</template>
</el-table-column>
const cellStyle = ({ row, column, rowIndex, columnIndex }) => {
// 状态列字体颜色
// columnIndex 列下标
// rowIndex 行下标
// row 行
// column 列
if (row.style == true && columnIndex === 3) {
return { color: "red" };
} else if(row.style == false && columnIndex === 3) {
return { color: "#ccc" };
}
}
在el-table标签上添加 :cell-style="cellStayle"
或者
直接在标签上改 用v-if控制显示
<template #default="scope">
<!-- {{scope.row.type ? "内部链接" : "外部链接"}} -->
<div v-if="scope.row.type" style="color: blue">内部链接</div>
<div v-else style="color: red">外部链接</div>
</template>
</el-table-column>