diff --git a/packages/renderless/package.json b/packages/renderless/package.json index 8416e3932f..26012586f2 100644 --- a/packages/renderless/package.json +++ b/packages/renderless/package.json @@ -1,6 +1,6 @@ { "name": "@opentiny/vue-renderless", - "version": "3.18.8", + "version": "3.18.9", "private": true, "description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.", "author": "OpenTiny Team", diff --git a/packages/renderless/src/tabs/index.ts b/packages/renderless/src/tabs/index.ts index 6859a65772..0b26103ae2 100644 --- a/packages/renderless/src/tabs/index.ts +++ b/packages/renderless/src/tabs/index.ts @@ -131,15 +131,20 @@ export const calcMorePanes = if (tabs && tabs.length) { let tabsAllWidth = 0 + + if (state.currentIndex === -1) { + state.currentIndex = state.panes.findIndex((item) => item.state.paneName === state.currentName) + } + const currentIndex = state.currentIndex < 0 ? 0 : state.currentIndex + const tabsHeaderWidth = tabNavRefs.navScroll.offsetWidth + for (let i = 0; i < tabs.length; i++) { const tabItem = tabs[i] as HTMLElement // 遮住元素一半则隐藏 tabsAllWidth = tabItem.offsetLeft + tabItem.offsetWidth / 2 - const tabsHeaderWidth = tabNavRefs.navScroll.offsetWidth - const currentName = Number(state.currentName || 0) - if (tabsAllWidth > tabsHeaderWidth && currentName >= 0) { - if (currentName >= i + 1) { - state.showPanesCount = currentName - 0 + if (tabsAllWidth > tabsHeaderWidth && currentIndex >= 0) { + if (currentIndex >= i + 1) { + state.showPanesCount = currentIndex } else { state.showPanesCount = i }