一、概述
現有一個基於element-ui開發的后台頁面,效果如下:

需要將公司名進行切割,每一行,顯示一個公司。
二、代碼實現
test.vue
<template> <el-table :data="tableData" border style="width: 362px"> <el-table-column prop="id" label="id" width="180"> </el-table-column> <el-table-column prop="name" label="公司名" width="180"> <template slot-scope="scope"> <div v-for="item in companyCut(scope.row.name)"> {{item}}<br> </div> </template> </el-table-column> </el-table> </template> <script> export default { name: "test", data() { return { tableData: [{ id: '2016-05-02', name: '阿里雲', }, { id: '2016-05-04', name: '騰訊控股、字節跳動', }, { id: '2016-05-01', name: '美團、金蝶國際、台積電', }] } }, methods: { // 切割公司列表 companyCut(name){ let company=name.split("、") return company }, } } </script> <style scoped> </style>
效果如下:

