直接上代碼,這樣不管在表格上邊有任何組件,都可以解決。下邊的這個50高度是用來放其他組件的,比如常見的分頁組件,如果你不需要的話,可以不用放。
this.$nextTick(function () {
//在頁面渲染完成後
this.height = window.innerHeight - this.$refs.table.$el.getBoundingClientRect().top - 50
this.$refs.table.$el.getBoundingClientRect().top //表格距離瀏覽器的高度
var that = this
// 添加監聽窗口大小變化事件
window.onresize = function () {
that.height = window.innerHeight - that.$refs.table.$el.getBoundingClientRect().top - 50
}
})