ps: 以下改变element-ui默认的样式时都不能加scoped
,可以加一个唯一前缀避免污染全局样式
改变默认样式都可以通过打开控制台查看层级和类名进行更改
.el-table .el-table__body-wrapper .el-table__body tr.el-table__row:hover > td{
background-color: #ffffff !important;
}
//less预处理器
.el-table--enable-row-hover{
.el-table__body{
tr:hover>td{
background-color: #ffffff !important;
}
}
}
.el-table__header tr,.el-table__header th {
padding: 0;
height: 40px;
}
.el-table__body tr,.el-table__body td {
height: 60px;
}
.el-table td, .el-table th.is-leaf,.el-table--border, .el-table--group{
border-color: #BFBFBF;
}
可以自行添加hover时的颜色
arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0 || columnIndex === 1 || columnIndex === 4) {
if (rowIndex % this.gridData.length === 0) {
return [this.tableData.length, 1]
} else {
return [0, 0]
}
}
},
从需求的最后一行开始向上合并可以解决这个问题
直接添加header-cell-style
CSS样式(不能添加scoped)
.el-table__header tr,.el-table__header th {
padding: 0;
height: 40px;
}
通过方法改变(更灵活,可以分开操作不同列的表头)
// js方法
getRowClass({ row, column, rowIndex, columnIndex }) {
if (rowIndex === 0 && columnIndex === 0) {
return "background-color:#E8E9EA;font-size:13px;border-top-left-radius: 5px";
}
if (rowIndex === 0 && columnIndex === 5) {
return "background-color:#E8E9EA;color:#606266;border-top-right-radius: 5px ";
}
if (rowIndex === 0 && columnIndex === 1) {
return "background-color:#E8E9EA;color:#303133;";
}
if (rowIndex === 0 && 1 < columnIndex < 5) {
return "background-color:#E8E9EA;color:#606266";
}
},
.el-tabs .payContent .el-table {
border-right: 1px solid #e8e9ea;
border-left: 1px solid #e8e9ea;
border-radius: 5px;
margin-top: 20px;
}
payContent
为唯一前缀,避免去除scoped后污染全局样式
绑定row-click
// js
rowMeth (row, column, event) {
console.log(row)
},
通过element自带的size
属性进行更改
通过css自行定义宽高
.inputClass {
.el-input__inner {
width: 240px;
height: 40px;
}
}
inputClass
为避免污染全局样式的唯一前缀
// js
rules: {
name: [
{ required: true, message: '请输入活动名称', trigger: 'blur' },
{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
],
region: [
{ required: true, message: '请选择活动区域', trigger: 'change' }
]
}
自定义验证规则
rules: {
age: [{
validator: (rule, value, callback) => {
if (value !== '') {
if ((/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/).test(value) === false) {
callback(new Error('请输入数字'))
} else {
callback()
}
} else {
callback()
}
},
type: 'number',
trigger: 'change'
}]
}
ps: 嵌套在表格中的对话框无法打开可以添加:append-to-body="true"
显示
title文字
.el-dialog__title{
somestyle
}
header
.el-dialog__header {
somestyle
}
content
.el-dialog__body{
somestyle
}
footer
.el-dialog__footer{
somestyle
}
整体内容
.el-dialog{
somestyle
}
ps:再重申一次,改变element-ui的默认样式时不能添加scoped
进行限制,并且应该自定义唯一前缀来避免污染全局样式
暂时记录这些,如有不懂可查阅官文或者私聊我,后期持续补充