HTML
//tableData为后台返回的数据,roleList为表格对象中的子数组
<el-table :data="tableData" style="width: 100%">
<el-table-column
label="所属角色"
min-width="160"
show-overflow-tooltip
>
<template slot-scope="scope">
<span
v-for="(item, index) in scope.row.roleList"
:key="index"
>{{item.roleName}}</span
>
</template>
</el-table-column>
</el-table>
效果图(实际是两个角色):
![](https://i-blog.csdnimg.cn/blog_migrate/f82d5c16f9cc722e830e15409aa54b03.png)
正确的HTML
//tableData为后台返回的数据,roleList为表格对象中的子数组
<el-table :data="tableData" style="width: 100%">
<el-table-column
label="所属角色"
min-width="160"
show-overflow-tooltip
>
<template slot-scope="scope">
<span
v-for="(item, index) in scope.row.roleList"
:key="index"
>{{scope.row.roleList.length-1!==index?item.roleName+',':item.roleName}}</span
>
</template>
</el-table-column>
</el-table>
正确的效果图(使用逗号隔开了的效果):
![](https://i-blog.csdnimg.cn/blog_migrate/ac4bb1654cc59d6a06f848170249b733.png)