Skip to content

Commit

Permalink
fix(tabBarItem): issues:TabbarItem component in the route mode fails …
Browse files Browse the repository at this point in the history
…to bind with v-model
  • Loading branch information
lzxiaoqi committed Oct 28, 2024
1 parent e445bef commit 8ba99e0
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions packages/vant/src/tabbar-item/TabbarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,11 @@ export default defineComponent({
const { $route } = vm;
const { to } = props;
const config = isObject(to) ? to : { path: to };
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 !!$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;
});
}

return (props.name ?? index.value) === modelValue;
Expand Down

0 comments on commit 8ba99e0

Please sign in to comment.