From f0cbcfa94969a4da548b006470ca994e0435645a Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 00:23:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AAlpine.js=20userInfo?= =?UTF-8?q?.position=5Fhistory=20=E5=88=9D=E5=A7=8B=20undefined=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20length=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - userInfo 初始值加 position_history: [],防止挂载时 undefined.length - x-text 和 x-if 里加可选链 ?.length ?? 0 双重兜底 --- resources/views/chat/partials/user-actions.blade.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/views/chat/partials/user-actions.blade.php b/resources/views/chat/partials/user-actions.blade.php index 9f2b170..d14ecee 100644 --- a/resources/views/chat/partials/user-actions.blade.php +++ b/resources/views/chat/partials/user-actions.blade.php @@ -77,7 +77,9 @@ function userCardComponent() { return { showUserModal: false, - userInfo: {}, + userInfo: { + position_history: [] + }, isMuting: false, muteDuration: 5, showWhispers: false, @@ -490,7 +492,7 @@ cursor: pointer; font-size: 11px; font-weight: bold; color: #7c3aed; margin-bottom: 4px; user-select: none;"> 🎖️ 职务履历 + x-text="'(' + (userInfo.position_history?.length ?? 0) + ' 条)'"> {{-- 折叠内容 --}} @@ -504,7 +506,7 @@ :style="h.is_active ? 'background: #7c3aed; box-shadow: 0 0 0 3px #ede9fe;' : 'background: #d1d5db;'"> -