From 71f9fd9639d948b59bbd0d77d535510c27e34a57 Mon Sep 17 00:00:00 2001 From: yaojn Date: Tue, 15 Apr 2025 15:56:02 +0800 Subject: [PATCH] =?UTF-8?q?-=20[=E4=BF=AE=E5=A4=8D]=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=A6=E6=83=85=E9=A1=B5=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=20$refs=20=E8=8E=B7=E5=8F=96=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E8=87=B4=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/pages/autoexec/detail/job-detail.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/views/pages/autoexec/detail/job-detail.vue b/src/views/pages/autoexec/detail/job-detail.vue index 83be6b9d..757937ba 100644 --- a/src/views/pages/autoexec/detail/job-detail.vue +++ b/src/views/pages/autoexec/detail/job-detail.vue @@ -256,13 +256,13 @@ export default { calculateJobNameMaxWidth() { setTimeout(() => { const divideWidth = 2; // 分割线宽度 - const topRightRef = this.$refs.topRightRef; - const jobDetailContainRef = this.$refs.jobDetailContain; - const statusRef = this.$refs.statusRef; - const userRef = this.$refs.userRef; - const {containTopRight} = jobDetailContainRef?.$refs || {}; - if (containTopRight) { - this.jobNameWidth = containTopRight.offsetWidth - topRightRef.offsetWidth - statusRef.offsetWidth - userRef.offsetWidth - divideWidth; + const getElementWidth = (ref) => this.$refs?.[ref]?.offsetWidth || 0; + const topRightWidth = getElementWidth('topRightRef'); + const statusWidth = getElementWidth('statusRef'); + const userWidth = getElementWidth('userRef'); + const containTopRightWidth = this.$refs?.jobDetailContain?.$refs?.containTopRight?.offsetWidth || 0; + if (containTopRightWidth) { + this.jobNameWidth = containTopRightWidth - topRightWidth - statusWidth - userWidth - divideWidth; } }, 200); // 延迟200毫秒执行,确保能拿到用户和状态的宽度,使用nextTick会导致计算不准确 }, -- Gitee