关于表格
1、通过slot-scope="scope"添加操作按钮
<el-table-column>
<template slot-scope="scope">
<el-button size="mini" type="primary">编辑</el-button>
<el-button size="mini" type="danger">删除</el-button>
</template>
</el-table-column>
2、通过scope.$index获取当前行下标
<el-table-column label="操作" width="160">
<template slot-scope="scope">
<el-button size="mini" type="primary" plain @click = "showIndex(scope.$index)">点击显示当前行下标</el-button>
</template>
</el-table-column>
3、scope.row获取当前行的属性值
<el-table-column label="操作" width="160">
<template slot-scope="scope">
<el-button size="mini" type="primary" plain @click = "showName(scope.row.name)">点击获取姓名属性</el-button>
</template>
</el-table-column>
4、设置表头样式 header-cell-class-name
//表头的设置
<el-table
:data="tableData[lang]"
class="table"
stripe
border
:header-cell-class-name="headerStyle"
>
//js中编写headerStyle,返回class名称tablestyle
headerStyle ({row, column, rowIndex, columnIndex}) {
return 'tableStyle'
}
//style中编写样式
<style lang = "scss">
.tableStyle{
background-color: #1989fa!important;
color:#fff;
font-weight:400;
}
</style>
//也可直接以对象的形式编写
<style lang = "scss">
.tableStyle{
background-color: #1989fa!important;
color:#fff;
font-weight:400;
}
</style>
等待更新。。。