mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Tab: should not swipe to disabled tab (#1704)
This commit is contained in:
parent
d05c8ed025
commit
fe3eb10bd3
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user