diff --git a/docs/examples/table/custom-column.vue b/docs/examples/table/custom-column.vue index 29685cfd89..cc553fc105 100644 --- a/docs/examples/table/custom-column.vue +++ b/docs/examples/table/custom-column.vue @@ -10,15 +10,13 @@ diff --git a/packages/components/table/src/config.ts b/packages/components/table/src/config.ts index 554d2bcf7b..4c4417403c 100644 --- a/packages/components/table/src/config.ts +++ b/packages/components/table/src/config.ts @@ -9,6 +9,11 @@ import type { TableColumnCtx } from './table-column/defaults' import type { Store } from './store' import type { TreeNode } from './table/defaults' +const defaultClassNames = { + selection: 'table-column--selection', + expand: 'table__expand-column', +} + export const cellStarts = { default: { order: '', @@ -18,7 +23,6 @@ export const cellStarts = { minWidth: 48, realWidth: 48, order: '', - className: 'el-table-column--selection', }, expand: { width: 48, @@ -34,6 +38,10 @@ export const cellStarts = { }, } +export const getDefaultClassName = (type) => { + return defaultClassNames[type] || '' +} + // 这些选项不应该被覆盖 export const cellForced = { selection: { @@ -105,9 +113,10 @@ export const cellForced = { return column.label || '' }, renderCell({ row, store }: { row: T; store: Store }) { - const classes = ['el-table__expand-icon'] + const { ns } = store + const classes = [ns.e('expand-icon')] if (store.states.expandRows.value.indexOf(row) > -1) { - classes.push('el-table__expand-icon--expanded') + classes.push(ns.em('expand-icon', 'expanded')) } const callback = function (e: Event) { e.stopPropagation() @@ -134,7 +143,6 @@ export const cellForced = { }, sortable: false, resizable: false, - className: 'el-table__expand-column', }, } @@ -170,18 +178,19 @@ export function treeCellPrefix({ e.stopPropagation() store.loadOrToggle(row) } + const { ns } = store if (treeNode.indent) { ele.push( h('span', { - class: 'el-table__indent', + class: ns.e('indent'), style: { 'padding-left': `${treeNode.indent}px` }, }) ) } if (typeof treeNode.expanded === 'boolean' && !treeNode.noLazyChildren) { const expandClasses = [ - 'el-table__expand-icon', - treeNode.expanded ? 'el-table__expand-icon--expanded' : '', + ns.e('expand-icon'), + treeNode.expanded ? ns.em('expand-icon', 'expanded') : '', ] let icon = ArrowRight if (treeNode.loading) { @@ -200,7 +209,7 @@ export function treeCellPrefix({ return [ h( ElIcon, - { class: { 'is-loading': treeNode.loading } }, + { class: { [ns.is('loading')]: treeNode.loading } }, { default: () => [h(icon)], } @@ -213,7 +222,7 @@ export function treeCellPrefix({ } else { ele.push( h('span', { - class: 'el-table__placeholder', + class: ns.e('placeholder'), }) ) } diff --git a/packages/components/table/src/filter-panel.vue b/packages/components/table/src/filter-panel.vue index a793a8b6c8..d28e7d2e3d 100644 --- a/packages/components/table/src/filter-panel.vue +++ b/packages/components/table/src/filter-panel.vue @@ -9,16 +9,16 @@ append-to-body effect="light" pure - popper-class="el-table-filter" + :popper-class="ns.b()" persistent >