<el-table-column label="电话" width="180">
<template slot-scope="scope">
<div v-if="scope.row.contact_1 != undefined">
<span v-for="(item,index) in scope.row.contact_1.mobile" :key="index">{{ item }}</span>
</div>
<div v-if="scope.row.contact_2 != undefined">
<span v-for="(item,index) in scope.row.contact_2.mobile" :key="index">{{ item }}</span>
</div>
<div v-if="scope.row.contact_3 != undefined">
<span v-for="(item,index) in scope.row.contact_3.mobile" :key="index">{{ item }}</span>
</div>
<div v-if="scope.row.contact_4 != undefined">
<span v-for="(item,index) in scope.row.contact_4.mobile" :key="index">{{ item }}</span>
</div>
<div v-if="scope.row.contact_5 != undefined">
<span v-for="(item,index) in scope.row.contact_5.mobile" :key="index">{{ item }}</span>
</div>
</template>
</el-table-column>
这种el-table表中的数据有什么简写的方式吗
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
想到好的再改 2021-12-23 15:24关注<div v-for="(item,index) in Object.keys(scope.row)" v-if="scope.row[item]!==undefined" :key="index"> <span v-for="(spanItem,spanIndex) in scope.row.[item].mobile" :key="spanIndex">{{ spanItem}}</span> </div>没试验过 基本逻辑没得问题
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用