https://www.cnblogs.com/whowhere/p/10029
通过 Scoped slot 可以获取到 row, column, $index 和 store(table 内部的状态管理)的数据:
{{scope.row}} =>获取整行的数据
{{scope.$index}} => 行的下标
使用:
<el-table <el-table-column
<template slot-scope="scope">
{{ scope.row.userSex === 1 ? "男" : "女" }} </template>
/el-table-column>
/el-table>
2.只绑定一个数据,例如:sex:'女'
<ui-table-column prop="userSex" label="性别" width="80px" :formatte r="getSexType" show-overflow-tooltip> </ui-table-column>
再通过formatter属性来格式化数据(定义没有数据的显示内容)如下:
getSexType(row, column) { return sexType(row[column.property]) }
row[column.property] => 获取表格里数据
sexType => 定义的公共方法(逻辑)
本文详细介绍了如何使用Element UI中的Scopedslot特性来获取表格数据,并展示了如何利用这些数据进行行的下标、整行数据的获取以及如何通过formatter属性来格式化表格中的特定数据,如性别字段的显示。
4110

被折叠的 条评论
为什么被折叠?



