表格
<el-table :data="tableData" style="width: 100%;margin-bottom: 20px;" row-key="id" border default-expand-all>
<el-table-column prop="name" label="日期" sortable width="180">
</el-table-column>
<el-table-column prop="price" label="姓名" sortable width="180">
</el-table-column>
<el-table-column prop="carfactory_detail" label="地址">
</el-table-column>
/*
该代理商属性为数组,每个地区有多个代理商,属性还是为data里面的属性caragency_detail,设置一个formatter对该行进行过滤
*/
<el-table-column prop="caragency_detail" label="代理商" :formatter="handleAgencys">
</el-table-column>
</el-table>
formatter
methods: {
handleAgencys(row){ // row代表每行数据
let arr=[]
row.caragency_detail.forEach((element) => { // 对每行数据中的数组字段进行遍历
console.log(element)
arr.push(element.agency_name)
})
console.log(arr)
return arr.join(',') // 将数组拼接成字符串显示
}
标签:arr,表格,elementui,prop,数组,element,table,row,属性
From: https://www.cnblogs.com/xunfei001/p/16861813.html