在 Vue.js 中,您可以使用 'slot-scope' 来访问数组对象内部的数组,并使用 'v-for' 指令来遍历内部数组,并将数据显示在 el-table 中。

例如:

<el-table :data="tableData">
  <el-table-column prop="name" label="Name"></el-table-column>
  <el-table-column label="Items">
    <template slot-scope="scope">
      <div v-for="(item, index) in scope.row.items" :key="index">{{ item }}</div>
    </template>
  </el-table-column>
</el-table>

在这个例子中,我们假设数据对象具有以下结构:

tableData: [
  {
    name: 'John',
    items: ['Apple', 'Banana', 'Orange']
  },
  {
    name: 'Mary',
    items: ['Grapes', 'Pineapple']
  }
]

通过使用 'slot-scope' 和 'v-for',我们可以在 el-table 内部第二列中显示每个对象的项目。

Vue.js: 如何在 El-Table 中展示数组对象内部数组数据

原文地址: https://www.cveoy.top/t/topic/oT3z 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录