刚开始显示这样
使用 :formatter="abc"都显示的是2,是为什么
<template>
<el-table
:data="tableData"
height="250"
border
style="width: 100%">
<el-table-column
prop="date"
label="日期"
width="180">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="180">
</el-table-column>
<el-table-column
prop="address"
label="地址">
</el-table-column>
<el-table-column
prop="jiBie"
label="级别"
:formatter="abc">
</el-table-column>
</el-table>
</template>
<script>
export default {
data() {
return {
tableData: [{
date: '2016-05-03',
name: '王小虎',
address: '50'
}, {
date: '2016-05-02',
name: '王小虎',
address: '80'
}]
}
},
methods:{
abc(fen){
const a=this.tableData.length;
for(let i=0;i<this.tableData.length;i++){
if(this.tableData[i].address==80){
return fen.jiBie=1;
}else if(this.tableData[i].address==50){
return fen.jiBie=2;
}
}
}
}
}
</script>