diff --git a/packages/vant/src/tabbar-item/TabbarItem.tsx b/packages/vant/src/tabbar-item/TabbarItem.tsx index 6043bea027e..e2f18de52b4 100644 --- a/packages/vant/src/tabbar-item/TabbarItem.tsx +++ b/packages/vant/src/tabbar-item/TabbarItem.tsx @@ -59,11 +59,17 @@ export default defineComponent({ const { $route } = vm; const { to } = props; const config = isObject(to) ? to : { path: to }; - return !!$route.matched.find((val) => { - const pathMatched = 'path' in config && config.path === val.path; - const nameMatched = 'name' in config && config.name === val.name; - return pathMatched || nameMatched; - }); + const pathMatched = + 'path' in config && + $route.matched.some((val) => config.path === val.path); + const nameMatched = + 'name' in config && + $route.matched.some((val) => config.name === val.name); + const isActive = pathMatched || nameMatched; + if (isActive) { + parent.setActive(props.name ?? index.value, () => {}); + } + return isActive; } return (props.name ?? index.value) === modelValue;