element组件
本篇博客主要说明一些element开发中会用到但是不太会记住的属性
1、label-position
通过 label-position 属性来改变表单域或标签的位置,可选的值有 top/left/right ,默认的是 right ,lable-position 必须要和 label-width(表单域标签的宽度,作为 Form 直接子元素的 form-item 会继承该值) 共同使用,才会生效。
lable-position 和 label-width一起使用!
通过 label-position 属性来改变表单域或标签的位置,可选的值有 top/left/right ,默认的是 right ,lable-position 必须要和 label-width(表单域标签的宽度,作为 Form 直接子元素的 form-item 会继承该值) 共同使用,才会生效。
<el-form
ref="loginForm"
:model="loginForm"
:rules="loginRules"
class="login-form"
label-position="right"
label-width="80px"
>
2、round 是否圆角按钮 boolean — false
<el-row>
<el-button round>圆角按钮</el-button>
<el-button type="primary" round>主要按钮</el-button>
<el-button type="success" round>成功按钮</el-button>
<el-button type="info" round>信息按钮</el-button>
<el-button type="warning" round>警告按钮</el-button>
<el-button type="danger" round>危险按钮</el-button>
</el-row>
3,element-ui 中的row-class-name属性
这个属性主要的是用来为每一行添加class,定义每一行的状态
对于这个属性的定义官方文档也有进行说明
<template>
<el-table
:data="tableData"
style="width: 100%"
:row-class-name="tableRowClassName"
>
<el-table-column prop="date" label="日期" width="180"> </el-table-column>
<el-table-column prop="name" label="姓名" width="180"> </el-table-column>
<el-table-column prop="address" label="地址"> </el-table-column>
</el-table>
methods: {
tableRowClassName({ row, rowIndex }) {
if (rowIndex === 1) {
return 'warning-row'
} else if (rowIndex === 3) {
return 'success-row'
}
return ''
},
}
}
<style>
.el-table .warning-row {
--el-table-tr-background-color: var(--el-color-warning-lighter);
}
.el-table .success-row {
--el-table-tr-background-color: var(--el-color-success-lighter);
}
</style>
对于这个属性的实现要在三个地方进行写出,:是为了绑定数据,如果去掉冒号,直接写返回值就可以了。
注意style中属性的写法
header-row-class-name | 表头行的 className 的回调方法,也可以使用字符串为所有表头行设置一个固定的 className。 | function({ row, rowIndex }) / string | — | — |
---|---|---|---|---|