feat(表格组件): 添加自定义展开/折叠图标样式

隐藏默认展开/折叠图标并替换为自定义图片资源
This commit is contained in:
zzp 2025-11-30 10:51:05 +08:00
parent 6997145f8c
commit 717110a061
3 changed files with 32 additions and 0 deletions

BIN
src/assets/packup_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

BIN
src/assets/unfold_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

View File

@ -163,4 +163,36 @@ defineExpose({
:deep(.el-table__row--level-1) { :deep(.el-table__row--level-1) {
background-color: #f0f0f0; background-color: #f0f0f0;
} }
/* 1. 隐藏默认图标 */
:deep(.el-table__expand-icon) {
/* 若只隐藏图标,保留容器: */
&::before,
& .el-icon--expand::before {
opacity: 0 !important; /* 透明化,保留点击区域 */
}
/* 若直接隐藏容器(慎用,会丢失点击区域): */
/* display: none !important; */
}
:deep(.el-table td.el-table__cell div) {
.el-icon {
opacity: 0 !important;
}
}
/* 2. 自定义折叠状态图标(示例:文件夹图标) */
:deep(.el-table__expand-icon) {
background: url('../../assets/packup_icon.png') no-repeat center;
background-size: 100% 100%; /* 图标大小 */
cursor: pointer;
}
/* 3. 自定义展开状态图标(示例:打开的文件夹) */
:deep(.el-table__expand-icon--expanded) {
background: url('../../assets/unfold_icon.png') no-repeat center;
background-size: 100% 100%; /* 图标大小 */
transform: rotate(90deg);
rotate: 90deg;
}
</style> </style>