chore: improve filter (#8262)

This commit is contained in:
neverland
2021-03-04 11:27:39 +08:00
committed by GitHub
parent 9fd71923f9
commit 12be46fad8
10 changed files with 31 additions and 37 deletions
+2 -2
View File
@@ -256,11 +256,11 @@ export default createComponent({
// correct the index of active tab
const setCurrentIndexByName = (name: number | string) => {
const matched = children.filter(
const matched = children.find(
(tab, index) => getTabName(tab, index) === name
);
const index = matched[0] ? children.indexOf(matched[0]) : 0;
const index = matched ? children.indexOf(matched) : 0;
setCurrentIndex(index);
};