Skip to content

Commit 475f981

Browse files
committed
Table: fix header scoped slot not accessing data
1 parent f33a656 commit 475f981

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

examples/docs/en-US/table.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ Customize table column so it can be integrated with other components.
15211521
### Table with custom header
15221522

15231523
Customize table header so it can be even more customized.
1524-
:::demo You can customize how the header looks by [Default slot content](https://vuejs.org/v2/guide/components-slots.html#Default-Slot-Content).
1524+
:::demo You can customize how the header looks by header [scoped slots](https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots).
15251525
```html
15261526
<template>
15271527
<el-table
@@ -1537,7 +1537,7 @@ Customize table header so it can be even more customized.
15371537
</el-table-column>
15381538
<el-table-column
15391539
align="right">
1540-
<template slot="header" slot-scope="slot">
1540+
<template slot="header" slot-scope="scope">
15411541
<el-input
15421542
v-model="search"
15431543
size="mini"
@@ -1581,8 +1581,12 @@ Customize table header so it can be even more customized.
15811581
}
15821582
},
15831583
methods: {
1584-
handleEdit(){},
1585-
handleDelete(){}
1584+
handleEdit(index, row) {
1585+
console.log(index, row);
1586+
},
1587+
handleDelete(index, row) {
1588+
console.log(index, row);
1589+
}
15861590
},
15871591
}
15881592
</script>

examples/docs/es/table.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ Personalice la columna de la tabla para que pueda integrarse con otros component
15201520
### Table with custom header
15211521

15221522
Customize table header so it can be even more customized.
1523-
:::demo You can customize how the header looks by [Default slot content](https://vuejs.org/v2/guide/components-slots.html#Default-Slot-Content).
1523+
:::demo You can customize how the header looks by header [scoped slots](https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots).
15241524
```html
15251525
<template>
15261526
<el-table
@@ -1536,7 +1536,7 @@ Customize table header so it can be even more customized.
15361536
</el-table-column>
15371537
<el-table-column
15381538
align="right">
1539-
<template slot="header" slot-scope="slot">
1539+
<template slot="header" slot-scope="scope">
15401540
<el-input
15411541
v-model="search"
15421542
size="mini"
@@ -1580,8 +1580,12 @@ Customize table header so it can be even more customized.
15801580
}
15811581
},
15821582
methods: {
1583-
handleEdit(){},
1584-
handleDelete(){}
1583+
handleEdit(index, row) {
1584+
console.log(index, row);
1585+
},
1586+
handleDelete(index, row) {
1587+
console.log(index, row);
1588+
}
15851589
},
15861590
}
15871591
</script>

examples/docs/zh-CN/table.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,11 +1686,11 @@
16861686
</el-table-column>
16871687
<el-table-column
16881688
align="right">
1689-
<template slot="header" slot-scope="slot">
1689+
<template slot="header" slot-scope="scope">
16901690
<el-input
16911691
v-model="search"
16921692
size="mini"
1693-
placeholder="Type to search"/>
1693+
placeholder="输入关键字搜索"/>
16941694
</template>
16951695
<template slot-scope="scope">
16961696
<el-button
@@ -1730,8 +1730,12 @@
17301730
}
17311731
},
17321732
methods: {
1733-
handleEdit(){},
1734-
handleDelete(){}
1733+
handleEdit(index, row) {
1734+
console.log(index, row);
1735+
},
1736+
handleDelete(index, row) {
1737+
console.log(index, row);
1738+
}
17351739
},
17361740
}
17371741
</script>

packages/table/src/table-column.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ export default {
453453
if (this.type === 'selection') {
454454
console.warn('[Element Warn][TableColumn]Selection column doesn\'t allow to set scoped-slot header.');
455455
} else {
456-
this.columnConfig.renderHeader = this.$scopedSlots.header;
456+
this.columnConfig.renderHeader = (h, scope) => this.$scopedSlots.header(scope);
457457
}
458458
}
459459

0 commit comments

Comments
 (0)