From c257cc4bac4828d983bff7992bccb9550096cf4d Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 25 Aug 2019 11:10:51 +0800 Subject: [PATCH] fix(Tabbar): incorrect active style in route mode (#4229) --- src/tabbar-item/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tabbar-item/index.js b/src/tabbar-item/index.js index 9339a2ac4..494041f11 100644 --- a/src/tabbar-item/index.js +++ b/src/tabbar-item/index.js @@ -1,4 +1,4 @@ -import { createNamespace, isObj } from '../utils'; +import { createNamespace, isObj, isDef } from '../utils'; import Icon from '../icon'; import Info from '../info'; import { route, routeProps } from '../utils/router'; @@ -28,7 +28,10 @@ export default createComponent({ const { to, $route } = this; if (to && $route) { const config = isObj(to) ? to : { path: to }; - return config.path === $route.path || config.name === $route.name; + const pathMatched = config.path === $route.path; + const nameMatched = isDef(config.name) && config.name === $route.name; + + return pathMatched || nameMatched; } } },