Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 为tabs组件添加showScrollbar属性 #643

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/component/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const tab = ref('例子')
| inactiveColor | 非活动标签文字颜色 | string | - | - | - |
| animated | 是否开启切换标签内容时的转场动画 | boolean | - | false | - |
| duration | 切换动画过渡时间,单位毫秒 | number | - | 300 | - |
| showScrollbar | 当标签可以滑动时是否显示滚动条 | boolean | - | false | $LOWEST_VERSION$ |

## Tab Attributes

Expand Down
8 changes: 7 additions & 1 deletion src/uni_modules/wot-design-uni/components/wd-tabs/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,10 @@
.wd-tabs__map-nav-btn {
width: 90px;
}
}
}

.hide-scrollbar::-webkit-scrollbar, .hide-scrollbar ::-webkit-scrollbar {
width: 0;
height: 0;
-webkit-appearance: none;
}
8 changes: 7 additions & 1 deletion src/uni_modules/wot-design-uni/components/wd-tabs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ export const tabsProps = {
/**
* 切换动画过渡时间,单位毫秒
*/
duration: makeNumberProp(300)
duration: makeNumberProp(300),
/**
* 控制是否出现滚动条
*
* 默认为 false
*/
showScrollbar: makeBooleanProp(true)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

修复 showScrollbar 属性的注释和默认值不一致

新添加的 showScrollbar 属性很好地实现了 PR 的目标。然而,注释中说明默认值为 false,但实际实现中默认值为 true。这种不一致可能会导致使用者混淆。

建议修改如下:

  1. 如果默认值应该是 true

    /**
     * 控制是否出现滚动条
     *
     * 默认为 true
     */
    showScrollbar: makeBooleanProp(true)
  2. 如果默认值应该是 false

    /**
     * 控制是否出现滚动条
     *
     * 默认为 false
     */
    showScrollbar: makeBooleanProp(false)

请确认正确的默认值,并相应地更新代码或注释。

}

export type TabsProps = ExtractPropTypes<typeof tabsProps>
13 changes: 11 additions & 2 deletions src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<template v-if="sticky">
<wd-sticky-box>
<view
:class="`wd-tabs ${customClass} ${slidableNum < items.length ? 'is-slide' : ''} ${mapNum < items.length && mapNum !== 0 ? 'is-map' : ''}`"
:class="`wd-tabs ${customClass}
${slidableNum < items.length ? 'is-slide' : ''}
${mapNum < items.length && mapNum !== 0 ? 'is-map' : ''}
${showScrollbar ? '' : 'hide-scrollbar'}
`"
:style="customStyle"
>
<wd-sticky :offset-top="offsetTop">
Expand Down Expand Up @@ -76,7 +80,12 @@
</template>

<template v-else>
<view :class="`wd-tabs ${customClass} ${slidableNum < items.length ? 'is-slide' : ''} ${mapNum < items.length && mapNum !== 0 ? 'is-map' : ''}`">
<view
:class="`wd-tabs ${customClass}
${slidableNum < items.length ? 'is-slide' : ''}
${mapNum < items.length && mapNum !== 0 ? 'is-map' : ''}
${showScrollbar ? '' : 'hide-scrollbar'}`"
>
<!--头部导航容器-->
<view class="wd-tabs__nav">
<view class="wd-tabs__nav--wrap">
Expand Down