diff --git a/packages/tabs/index.vue b/packages/tabs/index.vue index 8a158d329..4259c9b05 100644 --- a/packages/tabs/index.vue +++ b/packages/tabs/index.vue @@ -262,7 +262,8 @@ export default create({ }, setCurActive(active) { - if (active !== this.curActive) { + active = this.findAvailableTab(active, active < this.curActive); + if (this.isDef(active) && active !== this.curActive) { this.$emit('input', active); if (this.curActive !== null) { @@ -272,6 +273,16 @@ export default create({ } }, + findAvailableTab(index, reverse) { + const diff = reverse ? -1 : 1; + while (index >= 0 && index < this.tabs.length) { + if (!this.tabs[index].disabled) { + return index; + } + index += diff; + } + }, + // emit event when clicked onClick(index) { const { title, disabled } = this.tabs[index];