在<el-table-column>标签中的<template #default="scope">标签下添加<el-table-column>标签,可以通过scope.row访问el-table中的数据。例如,假设el-table的数据为:

tableData: [
  { name: 'John', age: 20 },
  { name: 'Jane', age: 25 },
  { name: 'Mike', age: 30 }
]

在<el-table-column>标签中的<template #default="scope">标签下添加<el-table-column>标签,可以通过scope.row访问el-table中的数据,如下所示:

<el-table :data="tableData">
  <el-table-column prop="name" label="Name"></el-table-column>
  <el-table-column label="Details">
    <template #default="scope">
      <el-table-column prop="age" label="Age"></el-table-column>
    </template>
  </el-table-column>
</el-table>

在上述示例中,el-table的第一列显示name属性,第二列是一个嵌套的<el-table-column>,其中的<template #default="scope">标签内部的<el-table-column>显示age属性。通过scope.row.age访问el-table中的数据。

这样,每一行的Details列都会显示相应的age属性值。

在 <el-table-column> 标签内嵌套 <el-table-column> 并使用数据

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

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