<el-table-column v-for="item in tableColums" :key="item.lable" :prop="item.prop" :label="item.label" :width="item.width">
<template slot-scope="scope">
<span v-if="item.formatter">{{item.formatter(scope.row)}}</span>
<span v-else-if="item.formatter2">{{item.formatter2(scope.row[item.prop])}}</span>
<span v-else>{{scope.row[item.prop]}}</span>
</template>
</el-table-column>
<script>
export default {
data() {
return {
tableColums:[
{prop:"time",
lable:"时间区间",
formatter:(obj)=>{
return `${obj.starttime}-${obj.endtime}`
},
{prop:"org",
lable:"组织",
formatter2:(ary)=>{
return ary?arr.filter(element =>element.scopeFlag === 'MO').map(element =>element.orgtx).join(','): '-'
},
}
]
}
}
</script>
element ui table组件<el-table-column v-for=“item in table“/>遍历写法的情况下formatter的用法。
最新推荐文章于 2024-03-12 09:49:26 发布