fixedTableHeaderMixin.js:
/*
使用此mixin,需要在页面的el-table配置属性:ref="table" 和 :height="tableHeight"。
举例:
<el-table ref="table" :height="tableHeight" v-loading="tableLoading" element-loading-text="拼命加载中" :data="tableData" style="width: 99%">
*/
export default {
data () {
return {
tableHeight: 250
}
},
mounted () {
this.$nextTick(() => {
this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 115
// 监听窗口大小变化
window.onresize = () => {
this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 115
}
})
}
}
参考:https://www.cnblogs.com/muou2125/p/9952491.html