From 314c2e8c9d08e806dd0ec78fd4b2aa5e536af8f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=A6=82=E6=91=B8=E9=B1=BC=E5=8E=BB?=
<1780903673@qq.com>
Date: Mon, 18 Nov 2024 13:14:03 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20tabs=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E5=B7=A6=E5=AF=B9=E9=BD=90=20(#718)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
✅ Closes: #380
---
docs/component/tabs.md | 20 ++++-
src/pages/tabs/Index.vue | 14 +++-
.../components/wd-tab/wd-tab.vue | 14 +++-
.../components/wd-tabs/index.scss | 6 ++
.../components/wd-tabs/types.ts | 29 ++++++-
.../components/wd-tabs/wd-tabs.vue | 78 +++++++++++--------
6 files changed, 121 insertions(+), 40 deletions(-)
diff --git a/docs/component/tabs.md b/docs/component/tabs.md
index 4feef460..d5560d11 100644
--- a/docs/component/tabs.md
+++ b/docs/component/tabs.md
@@ -127,16 +127,31 @@ const tab = ref('例子')
```
+## 左对齐超出即可滚动 1.3.15
+
+`slidable`设置为`always`时,所有的标签会向左侧收缩对齐,超出即可滑动。
+
+```html
+
+
+
+ 内容{{ item }}
+
+
+
+```
+
+
---
-标签页在标签数大于等于 6 个时,可以滑动;当标签数大于等于 10 个时,将会显示导航地图,便于快速定位到某个标签。可以通过设置 `slidable-num` 修改可滑动的数量阈值;设置 `map-num` 修改显示导航地图的阈值。
+标签页在标签数大于等于 6 个时,可以滑动;当标签数大于等于 10 个时,将会显示导航地图,便于快速定位到某个标签。可以通过设置 `slidable-num` 修改可滑动的数量阈值;设置 `map-num` 修改显示导航地图的阈值。`slidable`设置为`always`时,所有的标签会向左侧收缩对齐,超出即可滑动。
## Tabs Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
| ------------- | -------------------------------- | --------------- | ------ | ------ | -------- |
| v-model | 绑定值 | string / number | - | - | - |
-| slidable-num | 可滑动的标签数阈值 | number | - | 6 | - |
+| slidable-num | 可滑动的标签数阈值,`slidable`设置为`auto`时生效 | number | - | 6 | - |
| map-num | 显示导航地图的标签数阈值 | number | - | 10 | - |
| sticky | 粘性布局 | boolean | - | false | - |
| offset-top | 粘性布局时距离窗口顶部距离 | number | - | 0 | - |
@@ -147,6 +162,7 @@ const tab = ref('例子')
| inactiveColor | 非活动标签文字颜色 | string | - | - | - |
| animated | 是否开启切换标签内容时的转场动画 | boolean | - | false | - |
| duration | 切换动画过渡时间,单位毫秒 | number | - | 300 | - |
+| slidable | 是否开启滚动导航 | TabsSlidable | `always` | `auto` | $LOWEST_VERSION$ |
## Tab Attributes
diff --git a/src/pages/tabs/Index.vue b/src/pages/tabs/Index.vue
index 45d7c539..3ffa8cc1 100644
--- a/src/pages/tabs/Index.vue
+++ b/src/pages/tabs/Index.vue
@@ -74,7 +74,7 @@
-
+
内容{{ tab6 + 1 }}
@@ -83,6 +83,16 @@
+
+
+
+
+ 内容{{ tab9 + 1 }}
+
+
+
+
+
@@ -108,6 +118,8 @@ const tab5 = ref(0)
const tab6 = ref(0)
const tab7 = ref(0)
const tab8 = ref(0)
+const tab9 = ref(0)
+
const toast = useToast()
function handleClick({ index, name }: any) {
console.log('event', { index, name })
diff --git a/src/uni_modules/wot-design-uni/components/wd-tab/wd-tab.vue b/src/uni_modules/wot-design-uni/components/wd-tab/wd-tab.vue
index 1f9b45b7..6efda52c 100644
--- a/src/uni_modules/wot-design-uni/components/wd-tab/wd-tab.vue
+++ b/src/uni_modules/wot-design-uni/components/wd-tab/wd-tab.vue
@@ -1,6 +1,6 @@
-
+
@@ -16,8 +16,8 @@ export default {
}