| 123456789101112131415161718192021222324252627282930313233343536373839 | import { debounce } from 'lodash';export const onresizeHandler = {  data() {    return {      docmHeight: this.getDocumentHeight(),      showHeight: this.getDocumentHeight(),      isBtn: true // 是否显示隐藏保存提交按钮(演练登记&教育培训)    }  },  created() {},  watch: {    // 监听显示高度    showHeight: function() {      this.updateButtonVisibility();    }  },  mounted() {    // 添加事件监听器,并使用防抖处理函数    window.addEventListener('resize', this.handleResize);  },  beforeDestroy() {    // 移除事件监听器,避免内存泄漏    window.removeEventListener('resize', this.handleResize);  },  methods: {    handleResize: debounce(function() {      this.showHeight = this.getDocumentHeight();    }, 100), // 使用防抖,确保不频繁调用    updateButtonVisibility() {      this.isBtn = this.docmHeight <= this.showHeight;    },    // 获取文档高度的工具函数    getDocumentHeight() {      return document.documentElement.clientHeight || document.body.clientHeight;    }  }}
 |