From 8ba99e09704dab04a9aba75b4dd963971e172f5f Mon Sep 17 00:00:00 2001 From: lizhen <1154651716@qq.com> Date: Mon, 28 Oct 2024 12:26:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(tabBarItem):=20issues=EF=BC=9ATabbarItem=20?= =?UTF-8?q?component=20in=20the=20route=20mode=20fails=20to=20bind=20with?= =?UTF-8?q?=20v-model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vant/src/tabbar-item/TabbarItem.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/vant/src/tabbar-item/TabbarItem.tsx b/packages/vant/src/tabbar-item/TabbarItem.tsx index e2f18de52b4..6043bea027e 100644 --- a/packages/vant/src/tabbar-item/TabbarItem.tsx +++ b/packages/vant/src/tabbar-item/TabbarItem.tsx @@ -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;