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 all 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(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