<el-table-column label="状态" align="center" prop="state">
<template scope="scope">
<div :style="{'color':scope.row.state==0? 'red':scope.row.state==1? 'orange':scope.row.state==2? 'green':'#333'}">
{{scope.row.state|stateTrans}}
</div>
</template>
</el-table-column>
slot-scope=“scope” //取到当前单元格
scope.$index //拿到当前行的index
scope.row //拿到当前行的数据对象
scope.row.date //是对象里面的data属性的值
那么对于每一个el-table-column,我们只需要使用prop="date",就可以将该列的数据绑定为该数组所有的对象中的“date”属性,我们可以理解为对于tableData,这里始终取的是tableData[$index].date
table按照tableData这个数组的长度来生成多少行,按照有多少个el-table-column来生成多少列。
slot插槽
插槽有三种:默认插槽、具名插槽、作用域插槽。