1、需求:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e04610a83537d416703cf73cde51daf2.png)
通过点击右侧表格某一行(获取这一行的数据),将数据渲染到左侧
2、Table某一行的点击事件:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/157eeeee2087e268eb1ffc1d4851c3e9.png)
3、结果:
<template>
<el-table :data="tableData" stripe @row-click="handleTableRow" :highlight-current-row="true"
:header-cell-style="{ background: '#081832', color: '#fff' }">
// @row-click="handleTableRow"点击某一行事件;
//:highlight-current-row="true"选中当前行高亮
//:header-cell-style设置Table头的样式
<el-table-column type="selection" :reserve-selection="true" align="center" width="50" />
<el-table-column type="index" label="序号" align="center" width="50" />
</el-table>
</template>
<script>
export default {
data() {
return {
tableData: []
}
},
methods: {
handleTableRow(row, event, column) {
console.log(row, event, column)
}
}
}
</script>
<style scoped>
//设置行的样式
>>>.el-table tr {
background:
color:
}
//设置行的hover样式
>>>.el-table--enable-row-hover .el-table__body tr:hover>td.el-table__cell {
background: rgb(36, 148, 215);
color:
}
//设置行的active样式
>>>.el-table__body tr.current-row>td.el-table__cell {
background: rgb(4, 75, 137);
color:
}
</style>