export default { data() { return { elementHeight: null, contHeight: null } }, created() { this.getElHeight(0); }, mounted() { window.addEventListener('resize', this.getElHeight) }, beforeDestroy() { window.removeEventListener('resize', this.getElHeight); // 移除窗口大小变化监听器 }, methods: { // 设置表格高度 getElHeight(num) { this.$nextTick(() => { this.elementHeight = this.$refs.contBox.$el.clientHeight - this.$refs.headBox.offsetHeight - 124 - this.$refs.pagination.offsetHeight + num; }); }, } }