el-table 设置表头居中 ,表格内容某一列居中或左对齐或者右对齐,或者统一设置对齐样式
el-table 设置表头居中:header-cell-style=“headClass”==》methods中定义表头居中样式:cell-style=“rowClass”==》统一设置column的样式<el-tableref="multipleTable":data="commentData"tooltip-effect="dark"style="width: 100%;m
·
el-table 设置表头居中
:header-cell-style=“headClass” ==》methods中定义表头居中样式
:cell-style=“rowClass” ==》统一设置column的样式
<el-table
ref="multipleTable"
:data="commentData"
tooltip-effect="dark"
style="width: 100%;margin-top:15px;"//width:100%,每个column的width或min-width超出剩余宽度会出现横向滚动条,用来展示表格行内容
:stripe="true" //添加斑马纹
:cell-style="rowClass"//统一设置column的样式
:header-cell-style="headClass"//methods中定义
@selection-change="handleSelectionChange"//添加多选项
>
methods:
// 表头样式设置
headClass() {
return "text-align: center;background:#f7f7f7;";
},
// 表格样式设置
rowClass() {
return "text-align: center;";
},
单独设置某一列内容居中或者居左居右对齐给column加属性align:center/left/right将er-table的表格统一样式:cell-style删除即可
<el-table-column align="center" label="ISBN" width="150" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.bookNumber }}</template>
</el-table-column>
<el-table-column align="left" prop="bookName" label="图书名称" min-width="230" show-overflow-tooltip></el-table-column>
<el-table-column align="center" prop="author" label="作者" min-width="160" show-overflow-tooltip></el-table-column>
<el-table-column align="left" prop="press" label="出版社" min-width="160" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="图书大类" min-width="100" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.bookCategory }}</template>
</el-table-column>
更多推荐
已为社区贡献1条内容
所有评论(0)