当前位置:网站首页>Table custom style row class name in elemenui
Table custom style row class name in elemenui
2022-07-29 00:19:00 【Nanchang pengyuyan】
In daily development ,el-table It is a frequently used label , Sometimes you need to highlight something , Here's the picture :
List of official documents :
You can specify Table Component's row-class-name Attribute to Table Add... To a line in class, Indicates that the line is in some state .
Code :
<template>
<el-table :data="tableData" style="width: 100%" :row-class-name="tableRowClassName">
<el-table-column prop="date" label=" date " width="180">
</el-table-column>
<el-table-column prop="name" label=" full name " width="180">
</el-table-column>
<el-table-column prop="address" label=" Address ">
</el-table-column>
</el-table>
</template>
<style> .el-table .warning-row {
background: oldlace; } .el-table .success-row {
background: #f0f9eb; } </style>
<script> export default {
methods: {
tableRowClassName({
row, rowIndex}) {
if (rowIndex === 1) {
return 'warning-row'; } else if (rowIndex === 3) {
return 'success-row'; } return ''; } }, data() {
return {
tableData: [{
date: '2016-05-02', name: ' X.h. ', address: ' Jinshajiang road, putuo district, Shanghai 1518 get ', }, {
date: '2016-05-04', name: ' X.h. ', address: ' Jinshajiang road, putuo district, Shanghai 1518 get ' }, {
date: '2016-05-01', name: ' X.h. ', address: ' Jinshajiang road, putuo district, Shanghai 1518 get ', }, {
date: '2016-05-03', name: ' X.h. ', address: ' Jinshajiang road, putuo district, Shanghai 1518 get ' }] } } } </script>
According to the document , stay table Add to label :row-class-name=“tableRowClassName”, At the same time script Write what you want css style , It turns out that nothing has changed .
By looking at the review elements, you can find , The specified column has been assigned class, Here's the picture :
Compare official documents carefully , Only in style In style scoped There are differences in properties , There is no difference in other .
Only another one :
<style scoped> ::v-deep .el-result__title p {
color: red;
}
</style> <style> .el-table .warning-row {
background: oldlace !important;
}
</style>
stay elementUI in ,row-class-name、row-style、cell-class-name To be effective, you must use global class To take effect . Because the previous code was written in components , So remove the scoped The style in this component can be changed into a global attribute .
Of course, there is a flaw in doing so , It is easy to cause unexpected errors due to repeated style definitions , Therefore, the second solution is recommended .
Use depth selector /deep/ (css Add... Before the code /deep/ that will do )
/deep/ #myContent input{
/* ... */
}
Be careful , When using scss perhaps sass when , If you find that /deep/ Report errors , have access to ::deep Alternative solutions .
What I use here is scss
<style scoped> ::v-deep .el-table .warning-row {
background: oldlace !important;
}
::v-deep .el-result__title p {
color: red;
}
</style>
in addition , There's another pit :
If your form is set with stripe Property is set to true, Zebra stripes display , that row-class-name The effect will not be fully reflected , Only 1.3.5… Yes row-class-name The style of
in other words ,row-class-name Properties and stripe Mutually exclusive , Can't exist at the same time
边栏推荐
- What is in word?:^ p
- 【微服务】Nacos集群搭建以及加载文件配置
- How can Plato obtain premium income through elephant swap in a bear market?
- Linux之yum安装MySQL
- Advanced area of attack and defense world web masters -baby Web
- Leetcode62. Different paths
- Concurrency in go
- MySQL的存储过程
- Control fillet stroke materialshapedrawable
- Everything you have learned will come in handy at some point in your life (turn)
猜你喜欢

Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)

JS advanced ES6 ~ es13 new features

IDEA2021.2安装与配置(持续更新)

Simple use and understanding of laravel message queue

Sword finger offer 64. find 1+2+... +n, logical operator short circuit effect

Real time data warehouse: Netease strictly selects the practice of real-time data warehouse based on Flink

Android studio连接MySQL并完成简单的登录注册功能

【MySQL系列】MySQL数据库基础

Okaleido ecological core equity Oka, all in fusion mining mode

研发效能的道法术器
随机推荐
Event extraction and documentation (2008-2017)
110道 MySQL面试题及答案 (持续更新)
Leetcode61. rotating linked list
MySql中的like和in走不走索引
IDEA报错Error running ‘Application‘ Command line is too long解决方案
centos7安装mysql8
Multi sensor fusion positioning (I) -- 3D laser odometer
Concurrency in go
[applet project development -- JD mall] uni app commodity classification page (first)
Web系统常见安全漏洞介绍及解决方案-sql注入
Sword finger offer 55 - I. depth of binary tree
Opencv macro definition
Real time data warehouse: meituan's implementation of real-time data warehouse construction based on Flink
Linux下安装Mysql5.7,超详细完整教程,以及云mysql连接
MySQL的存储过程
Es6操作教程
How NAT configures address translation
Oracle create tablespaces and users
Worthington - chemical properties and related studies of Worthington trypsin
JS advanced ES6 ~ es13 new features