Skip to content

Instantly share code, notes, and snippets.

@sunzsh
Last active June 19, 2023 05:51
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save sunzsh/a2b632d438ea819f8224928a5efbec2d to your computer and use it in GitHub Desktop.
Save sunzsh/a2b632d438ea819f8224928a5efbec2d to your computer and use it in GitHub Desktop.
带分页打印表头的el-table
<script>
import { Table } from 'element-ui';
export default {
extends: Table,
mounted() {
this.$nextTick(function () {
let thead = this.$el.querySelector('.el-table__header-wrapper thead');
let theadNew = thead.cloneNode(true);
this.$el.querySelector('.el-table__body-wrapper table').appendChild(theadNew);
})
},
}
</script>
<style scoped>
.el-table >>> .el-table__body-wrapper thead {
display: none;
}
@media print {
.el-table >>> .el-table__header-wrapper {
display: none;
}
.el-table >>> .el-table__body-wrapper thead {
display: table-header-group;
}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment