Skip to content

Commit

Permalink
feat: update header render
Browse files Browse the repository at this point in the history
see more #21320
  • Loading branch information
yolofit committed Sep 26, 2021
1 parent 492ab00 commit e077f25
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/table/src/table-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,20 @@ export default {
},

setColumnRenders(column) {
// renderHeader 属性不推荐使用。
if (this.renderHeader) {
console.warn('[Element Warn][TableColumn]Comparing to render-header, scoped-slot header is easier to use. We recommend users to use scoped-slot header.');
} else if (column.type !== 'selection') {
column.renderHeader = (h, scope) => {
const renderHeader = this.$scopedSlots.header;
return renderHeader ? renderHeader(scope) : column.label;
const that = this;
if (column.type !== 'selection') {
column.renderHeader = function(h, scope) {
const headerSlot = that.$scopedSlots.header;
if (headerSlot) {
return headerSlot(scope);
} else if (that.renderHeader) {
console.warn('[Element Warn][TableColumn]Comparing to render-header, scoped-slot header is easier to use. We recommend users to use scoped-slot header.');
// renderHeader 属性不推荐使用。
// "this" equal to TableHeader._renderProxy
return that.renderHeader.call(this, h, scope);
} else {
return column.label;
}
};
}

Expand Down

0 comments on commit e077f25

Please sign in to comment.