element ui table组件<el-table-column v-for=“item in table“/>遍历写法的情况下formatter的用法。

<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>

详细解释一下这段代码<template> <div> <div class="wrap"> <el-table :data="orders"> <el-table-column prop="oid" label="订单编号" width="180" /> <el-table-column prop="ctime" label="创建时间" width="180" /> <el-table-column prop="money" label="金额" /> <el-table-column prop="payType" :formatter="formatterPayType" label="支付方式" /> <el-table-column prop="uname" label="收件人" /> <el-table-column prop="phone" label="收件人手机号" /> <el-table-column prop="address" label="收件地址" /> <el-table-column prop="waybill" label="运单号" :formatter="formatterWayBill"/> <el-table-column label="详细" > <template #default="scope"> <el-button type="primary" @click="seeDetail(scope.row)">详情</el-button> </template> </el-table-column> </el-table> </div> <el-dialog v-model="detailShow" title="订单详细" width="70%"> <el-table :data="goods"> <el-table-column prop="mainImg" label="商品图片"> <template #default="scope"> <el-image style="width: 70px; height: 70px" :src="scope.row.mainImg" alt="" :fit="fill" ></el-image> </template> </el-table-column> <el-table-column prop="bname" label="商品名称" /> <el-table-column prop="price" label="单价" /> <el-table-column prop="uname" label="数量" :formatter="formatterNum"/> </el-table> <template #footer> <span class="dialog-footer"> <el-button type="danger" @click="openFeedBack">反馈</el-button> </span> </template> </el-dialog> <el-dialog v-model="feedbackShow" title="反馈" width="70%" @close="clodeFeedback"> <el-input v-model="textarea" :rows="4" type="textarea" placeholder="请输入你遇到的问题" /> <span style="font-family: 'Arial Rounded MT Bold';font-weight: bold;"> {{feedBackDetail.respondent}} </span> <span>{{feedBackDetail.replyContent}}</span> <template #footer>
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值