diff --git a/src/tabs/README.md b/src/tabs/README.md index 70c60b4..d65754f 100644 --- a/src/tabs/README.md +++ b/src/tabs/README.md @@ -18,11 +18,11 @@ spline: base {{ icon }} - +{{ custom }} ### 不同尺寸的选项卡 @@ -40,10 +40,10 @@ spline: base 提供 上、右、下、左 不同位置的选项卡。 {{ position }} - +{{ combination }} ### 带禁用状态的选项卡 diff --git a/src/tabs/TabBar.tsx b/src/tabs/TabBar.tsx index 92e324b..adb1b12 100644 --- a/src/tabs/TabBar.tsx +++ b/src/tabs/TabBar.tsx @@ -1,4 +1,4 @@ -import { Component, createRef, tag } from 'omi'; +import { Component, createRef, signal, tag } from 'omi'; import classname, { getClassPrefix } from '../_util/classname'; import { StyledProps, Styles } from '../common'; @@ -25,7 +25,7 @@ export default class TabBar extends Component { currentActiveIdRef = createRef(); - barStyle: Styles = {}; + barStyle: Omi.SignalValue = signal({}); tabsClassPrefix = `${getClassPrefix()}-tabs`; @@ -49,11 +49,11 @@ export default class TabBar extends Component { }); const computedItem = itemsRef[this.currentActiveIdRef.current]; if (!computedItem) { - this.barStyle = { transform: `${transformPosition}(${0}px)`, [barBorderProp]: 0 }; + this.barStyle.value = { transform: `${transformPosition}(${0}px)`, [barBorderProp]: 0 }; return; } const itemPropValue = getComputedStyle(computedItem)[itemProp]; - this.barStyle = { transform: `${transformPosition}(${offset}px)`, [barBorderProp]: itemPropValue || 0 }; + this.barStyle.value = { transform: `${transformPosition}(${offset}px)`, [barBorderProp]: itemPropValue || 0 }; } } } @@ -65,10 +65,7 @@ export default class TabBar extends Component { } installed(): void { - setTimeout(() => { - this.computeStyle(); - this.update(); - }, 0); + this.computeStyle(); } render() { @@ -83,7 +80,7 @@ export default class TabBar extends Component { [`${this.tabsClassPrefix}__bar`]: true, [`${getClassPrefix()}-is-${tabPosition}`]: true, })} - style={this.barStyle} + style={this.barStyle.value} > ); } diff --git a/src/tabs/_example/combination.tsx b/src/tabs/_example/combination.tsx index 92594e7..e7da36b 100644 --- a/src/tabs/_example/combination.tsx +++ b/src/tabs/_example/combination.tsx @@ -5,7 +5,8 @@ import 'tdesign-web-components/tabs'; import { Component, signal } from 'omi'; export default class Combination extends Component { - theme = signal('normal'); + // 目前常规性滚动存在bug,先固定选择卡片型 + theme = signal('card'); scrollPosition = signal('auto'); @@ -17,7 +18,7 @@ export default class Combination extends Component { render() { return ( - { @@ -26,7 +27,7 @@ export default class Combination extends Component { > - + */}