diff --git a/packages/tabs/index.vue b/packages/tabs/index.vue index 3bdc3a94d..effefd50f 100644 --- a/packages/tabs/index.vue +++ b/packages/tabs/index.vue @@ -293,7 +293,7 @@ export default create({ this.$nextTick(() => { const { tabs } = this.$refs; - if (!tabs || this.type !== 'line') { + if (!tabs || !tabs[this.curActive] || this.type !== 'line') { return; } @@ -357,14 +357,13 @@ export default create({ scrollIntoView(immediate) { const { tabs } = this.$refs; - if (!this.scrollable || !tabs) { + if (!this.scrollable || !tabs || !tabs[this.curActive]) { return; } - const tab = tabs[this.curActive]; const { nav } = this.$refs; const { scrollLeft, offsetWidth: navWidth } = nav; - const { offsetLeft, offsetWidth: tabWidth } = tab; + const { offsetLeft, offsetWidth: tabWidth } = tabs[this.curActive]; this.scrollTo(nav, scrollLeft, offsetLeft - (navWidth - tabWidth) / 2, immediate); },