elementUI table 绑定数据

1.绑定一条数据用: => slot-scope属性,再显示对应的数据
通过 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 => 定义的公共方法(逻辑)
原文地址:https://www.cnblogs.com/LWJ-booke/p/8491367.html