mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(Tabs): using slot instead of render props (#10123)
This commit is contained in:
parent
fa5e4e2591
commit
55303595af
@ -361,6 +361,7 @@ export default defineComponent({
|
|||||||
const renderNav = () =>
|
const renderNav = () =>
|
||||||
children.map((item, index) => (
|
children.map((item, index) => (
|
||||||
<TabsTitle
|
<TabsTitle
|
||||||
|
v-slots={{ title: item.$slots.title }}
|
||||||
id={`${id}-${index}`}
|
id={`${id}-${index}`}
|
||||||
ref={setTitleRefs(index)}
|
ref={setTitleRefs(index)}
|
||||||
type={props.type}
|
type={props.type}
|
||||||
@ -370,7 +371,6 @@ export default defineComponent({
|
|||||||
isActive={index === state.currentIndex}
|
isActive={index === state.currentIndex}
|
||||||
controls={item.id}
|
controls={item.id}
|
||||||
scrollable={scrollable.value}
|
scrollable={scrollable.value}
|
||||||
renderTitle={item.$slots.title}
|
|
||||||
activeColor={props.titleActiveColor}
|
activeColor={props.titleActiveColor}
|
||||||
inactiveColor={props.titleInactiveColor}
|
inactiveColor={props.titleInactiveColor}
|
||||||
onClick={(event: MouseEvent) => onClickTab(item, index, event)}
|
onClick={(event: MouseEvent) => onClickTab(item, index, event)}
|
||||||
|
@ -19,12 +19,11 @@ export default defineComponent({
|
|||||||
controls: String,
|
controls: String,
|
||||||
scrollable: Boolean,
|
scrollable: Boolean,
|
||||||
activeColor: String,
|
activeColor: String,
|
||||||
renderTitle: Function,
|
|
||||||
inactiveColor: String,
|
inactiveColor: String,
|
||||||
showZeroBadge: truthProp,
|
showZeroBadge: truthProp,
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props) {
|
setup(props, { slots }) {
|
||||||
const style = computed(() => {
|
const style = computed(() => {
|
||||||
const style: CSSProperties = {};
|
const style: CSSProperties = {};
|
||||||
const { type, color, disabled, isActive, activeColor, inactiveColor } =
|
const { type, color, disabled, isActive, activeColor, inactiveColor } =
|
||||||
@ -56,7 +55,7 @@ export default defineComponent({
|
|||||||
const renderText = () => {
|
const renderText = () => {
|
||||||
const Text = (
|
const Text = (
|
||||||
<span class={bem('text', { ellipsis: !props.scrollable })}>
|
<span class={bem('text', { ellipsis: !props.scrollable })}>
|
||||||
{props.renderTitle ? props.renderTitle() : props.title}
|
{slots.title ? slots.title() : props.title}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user