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底部条颜色支持自由设置 #782

Open
wants to merge 2 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 @@ -263,6 +263,7 @@ function handlePopupShow() {
| autoLineWidth | 底部条宽度跟随文字,指定`lineWidth`时此选项不生效 | boolean | - | false | 1.4.0 |
| lineWidth | 底部条宽度,单位像素 | number | - | 19 | - |
| lineHeight | 底部条高度,单位像素 | number | - | 3 | - |
| lineBgColor | 底部条颜色 | string | - | #4d80f0 | $LOWEST_VERSION$ |
| color | 文字颜色 | string | - | - | - |
| inactiveColor | 非活动标签文字颜色 | string | - | - | - |
| animated | 是否开启切换标签内容时的转场动画 | boolean | - | false | - |
Expand Down
4 changes: 4 additions & 0 deletions src/uni_modules/wot-design-uni/components/wd-tabs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export const tabsProps = {
* 底部条高度,单位像素
*/
lineHeight: numericProp,
/**
* 底部条颜色
*/
lineBgColor: makeStringProp(''),
/**
* 颜色
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function toggleMap() {
*/
async function updateLineStyle(animation: boolean = true) {
if (!state.inited) return
const { autoLineWidth, lineWidth, lineHeight } = props
const { autoLineWidth, lineWidth, lineHeight, lineBgColor } = props
try {
const lineStyle: CSSProperties = {}
if (isDef(lineWidth)) {
Expand All @@ -320,6 +320,9 @@ async function updateLineStyle(animation: boolean = true) {
lineStyle.width = addUnit(textWidth)
}
}
if (isDef(lineBgColor)) {
lineStyle.background = addUnit(lineBgColor)
}
if (isDef(lineHeight)) {
lineStyle.height = addUnit(lineHeight)
lineStyle.borderRadius = `calc(${addUnit(lineHeight)} / 2)`
Expand Down