在 el-table-column 中使用插槽(slot)来显示图片却报Cannot read properties of undefined (reading 'row')
时间: 2023-07-14 07:14:13 浏览: 198
这个错误可能是因为您在使用插槽时没有正确地传递数据。在 `el-table-column` 中使用插槽时,您需要使用 `scoped-slot` 并将 `row` 数据传递给插槽。
例如,如果您的代码类似于以下代码:
```html
<template>
<el-table :data="tableData">
<el-table-column label="图片">
<template>
<img :src="row.imageUrl">
</template>
</el-table-column>
</el-table>
</template>
```
那么您需要将插槽改为 `scoped-slot` 并将 `row` 作为参数传递:
```html
<template>
<el-table :data="tableData">
<el-table-column label="图片">
<template slot-scope="scope">
<img :src="scope.row.imageUrl">
</template>
</el-table-column>
</el-table>
</template>
```
这样就应该可以正确地获取到 `row` 数据并显示图片了。
阅读全文
相关推荐





