Merge branch '2.x' into dev

This commit is contained in:
chenjiahan
2020-10-31 18:19:32 +08:00
29 changed files with 324 additions and 69 deletions
+16 -8
View File
@@ -218,15 +218,23 @@ export default createComponent({
};
const setCurrentIndex = (currentIndex) => {
currentIndex = findAvailableTab(currentIndex);
const newIndex = findAvailableTab(currentIndex);
if (isDef(currentIndex) && currentIndex !== state.currentIndex) {
const shouldEmitChange = state.currentIndex !== null;
state.currentIndex = currentIndex;
emit('update:active', currentName.value);
if (!isDef(newIndex)) {
return;
}
const newTab = children[newIndex];
const newName = getTabName(newTab, newIndex);
const shouldEmitChange = state.currentIndex !== null;
state.currentIndex = newIndex;
if (newName !== props.active) {
emit('update:active', newName);
if (shouldEmitChange) {
emit('change', currentName.value, children[currentIndex].title);
emit('change', newName, newTab.title);
}
}
};
@@ -377,9 +385,9 @@ export default createComponent({
watch(
() => children.length,
() => {
setCurrentIndexByName(props.active || currentName.value);
setLine();
nextTick(() => {
setCurrentIndexByName(props.active || currentName.value);
setLine();
scrollIntoView(true);
});
}