fix(Tabs): fix disabled event data (#2758)

This commit is contained in:
Waiter 2020-02-14 15:19:02 +08:00 committed by GitHub
parent 438d97eca3
commit 6ea006006f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,19 +137,19 @@ VantComponent({
this.setCurrentIndexByName(this.getCurrentName() || data.active); this.setCurrentIndexByName(this.getCurrentName() || data.active);
}, },
trigger(eventName: string) { trigger(eventName: string, child?: TrivialInstance) {
const { currentIndex } = this.data; const { currentIndex } = this.data;
const child = this.children[currentIndex]; const currentChild = child || this.children[currentIndex];
if (!isDef(child)) { if (!isDef(currentChild)) {
return; return;
} }
this.$emit(eventName, { this.$emit(eventName, {
index: currentIndex, index: currentChild.index,
name: child.getComputedName(), name: currentChild.getComputedName(),
title: child.data.title title: currentChild.data.title
}); });
}, },
@ -158,7 +158,7 @@ VantComponent({
const child = this.children[index]; const child = this.children[index];
if (child.data.disabled) { if (child.data.disabled) {
this.trigger('disabled'); this.trigger('disabled', child);
} else { } else {
this.setCurrentIndex(index); this.setCurrentIndex(index);
wx.nextTick(() => { wx.nextTick(() => {