|
@@ -3,20 +3,20 @@
|
|
|
* @param router
|
|
|
* @returns {boolean}
|
|
|
*/
|
|
|
-function getHasRouteMatched(router) {
|
|
|
- var pathName = location.pathname;
|
|
|
- var baseName = router.options.base;
|
|
|
- var pathIndex = pathName.indexOf(baseName);
|
|
|
-
|
|
|
+function getHasRouteMatched (router) {
|
|
|
+ var pathName = location.pathname
|
|
|
+ var baseName = router.options.base
|
|
|
+ var pathIndex = pathName.indexOf(baseName)
|
|
|
+ // 存在别名情况,需要额外匹配
|
|
|
+ var nowPath = pathName
|
|
|
if (pathIndex > -1) {
|
|
|
- var nowPath = pathName.slice(pathIndex + baseName.length);
|
|
|
- var { route } = router.resolve({
|
|
|
- path: nowPath,
|
|
|
- });
|
|
|
- var hasRouteMatched = route.matched.length > 0;
|
|
|
- return hasRouteMatched;
|
|
|
+ nowPath = pathName.slice(pathIndex + baseName.length)
|
|
|
}
|
|
|
- return false;
|
|
|
+ var { route } = router.resolve({
|
|
|
+ path: nowPath
|
|
|
+ })
|
|
|
+ var hasRouteMatched = route.matched.length > 0
|
|
|
+ return hasRouteMatched
|
|
|
}
|
|
|
|
|
|
/**
|