1、单页面使用
<el-table :data="sontableData" :height="tableHeight">
<script>
export default {
data(){
return{
tableHeight:[]
}
},
mounted:function(){
this.$nextTick(function () {
this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 250;
let self = this;
window.onresize = function() {
self.tableHeight = window.innerHeight - self.$refs.table.$el.offsetTop - 250
}
})
},
}
</script>
2、全局注册使用
1)新建tableHeight.js
export function tableHight(){
this.$nextTick(function () {
this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 250;
let self = this;
window.onresize = function() {
self.tableHeight = window.innerHeight - self.$refs.table.$el.offsetTop - 250
}
})
}
2)main.js注册
//table高度
import tableHeight from './libs/tableHight'
Vue.prototype.$tableHight=tableHeight
3)使用
mounted(){
this.$tableHeight();
},