From 7d7dc1ccc5d1b22c6c8896fd6ae0026e5de0831d Mon Sep 17 00:00:00 2001 From: zoujing Date: Wed, 11 Mar 2026 11:49:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=AB=E9=80=9F=E9=A2=84=E5=AE=9A?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages-quick/components/Tabs/index.vue | 192 ++---------------- .../components/Tabs/styles/index.scss | 71 ++++--- 2 files changed, 55 insertions(+), 208 deletions(-) diff --git a/src/pages-quick/components/Tabs/index.vue b/src/pages-quick/components/Tabs/index.vue index b22325f..be3ec2f 100644 --- a/src/pages-quick/components/Tabs/index.vue +++ b/src/pages-quick/components/Tabs/index.vue @@ -1,15 +1,16 @@ - - diff --git a/src/pages-quick/components/Tabs/styles/index.scss b/src/pages-quick/components/Tabs/styles/index.scss index 6779ddb..4f8b415 100644 --- a/src/pages-quick/components/Tabs/styles/index.scss +++ b/src/pages-quick/components/Tabs/styles/index.scss @@ -1,10 +1,24 @@ .tab-wrapper { background-color: $theme-color-100; height: 48px; + overflow-x: auto; + /* 支持横向滚动 */ + -webkit-overflow-scrolling: touch; + /* 平滑滚动(移动端) */ + white-space: nowrap; + /* 防止换行 */ + justify-content: flex-start; + /* 覆盖工具类,靠左排列以便滚动 */ } .tab-item { height: 100%; + flex: 0 0 auto; + /* 不让子项拉伸,按内容宽度排列 */ + padding: 0 12px; + /* 增加横向间距,便于触控 */ + min-width: 56px; + /* 保证可点击区域 */ } .icon { @@ -12,6 +26,13 @@ width: 20px; } +/* 组件模板中使用了绝对定位的内部元素,为保证父元素宽度基于内容,重置该子元素为静态布局 */ +.tab-item>.absolute { + position: static !important; + display: flex; + align-items: center; +} + .tab-item-active { &::before { content: ""; @@ -33,40 +54,32 @@ z-index: 3; } -.tab-indicator { +/* 已改为每项内部指示器,移除了全局指示器样式 */ + +/* 每项内的指示器(替代全局指示器) */ +.tab-item-inner { + display: inline-flex; + align-items: center; + position: relative; + z-index: 3; + /* 确保内容(icon/text)位于 .tab-item-active::before 之上 */ +} + +.tab-item-indicator { + position: absolute; bottom: 0; + left: 50%; + transform: translateX(-50%) scaleX(0.9); height: 3px; + width: 20px; background-color: $theme-color-500; border-radius: 4px 4px 0 0; - transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), - width 0.3s cubic-bezier(0.4, 0, 0.2, 1); - z-index: 3; - transform: translateZ(0); /* 启用硬件加速 */ - will-change: left, width; /* 优化动画性能 */ - - /* 初始状态:未初始化时隐藏 */ opacity: 0; - width: 20px; /* 默认宽度15px */ - left: 0; + transition: opacity 0.2s ease, transform 0.2s ease; + z-index: 3; } -/* 已初始化状态 */ -.tab-indicator.initialized { +.tab-item-indicator.visible { opacity: 1; -} - -/* 动画增强 */ -@keyframes tabSwitch { - 0% { - transform: translateZ(0) scaleX(0.8); - opacity: 0.6; - } - 100% { - transform: translateZ(0) scaleX(1); - opacity: 1; - } -} - -.tab-indicator.animating { - animation: tabSwitch 0.3s ease-out; -} + transform: translateX(-50%) scaleX(1); +} \ No newline at end of file