mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-03 19:58:09 +08:00
refactor(components): [tabs] enhance instance type (#14352)
* refactor(components): [tabs] enhance instance type 1. exports Tabs instance type 2. add expose type to TabNavInstanec * chore: remove useless import
This commit is contained in:
parent
99e8736c6a
commit
bfff514f77
@ -406,5 +406,8 @@ const TabNav = defineComponent({
|
||||
},
|
||||
})
|
||||
|
||||
export type TabNavInstance = InstanceType<typeof TabNav>
|
||||
export type TabNavInstance = InstanceType<typeof TabNav> & {
|
||||
scrollToActiveTab: () => Promise<void>
|
||||
removeFocus: () => void
|
||||
}
|
||||
export default TabNav
|
||||
|
@ -79,7 +79,7 @@ export type TabsEmits = typeof tabsEmits
|
||||
|
||||
export type TabsPanes = Record<number, TabsPaneContext>
|
||||
|
||||
export default defineComponent({
|
||||
const Tabs = defineComponent({
|
||||
name: 'ElTabs',
|
||||
|
||||
props: tabsProps,
|
||||
@ -112,9 +112,6 @@ export default defineComponent({
|
||||
emit('tabChange', value)
|
||||
}
|
||||
|
||||
// call exposed function, Vue doesn't support expose in typescript yet.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
nav$.value?.removeFocus?.()
|
||||
}
|
||||
} catch {}
|
||||
@ -166,9 +163,6 @@ export default defineComponent({
|
||||
|
||||
watch(currentName, async () => {
|
||||
await nextTick()
|
||||
// call exposed function, Vue doesn't support expose in typescript yet.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
nav$.value?.scrollToActiveTab()
|
||||
})
|
||||
|
||||
@ -244,3 +238,9 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export type TabsInstance = InstanceType<typeof Tabs> & {
|
||||
currentName: TabPaneName
|
||||
}
|
||||
|
||||
export default Tabs
|
||||
|
Loading…
Reference in New Issue
Block a user