diff --git a/src/components/mouseMenu/main.js b/src/components/mouseMenu/main.js index e64124cb..296dadd3 100644 --- a/src/components/mouseMenu/main.js +++ b/src/components/mouseMenu/main.js @@ -41,8 +41,10 @@ export default class MouseMenu extends React.Component { } render() { let menuList = this.state.activeMenuList;//路由表 - const pathname = window.location.href.lastIndexOf('\/'); - const pathnamestr = window.location.href.substr(pathname); + let urlHref=(window.location.href).replace(/^\/|\/$/g, ''); + const pathname = urlHref.lastIndexOf("/"); + const pathnamestr = urlHref.substr(pathname); + return (
diff --git a/src/components/subnav/main.js b/src/components/subnav/main.js index 6f6d0b36..2070c54d 100644 --- a/src/components/subnav/main.js +++ b/src/components/subnav/main.js @@ -83,9 +83,9 @@ export default class topNav extends React.Component { let history0 = window.history.length <= 1; let routeflag = sessionStorage.getItem("showflag"); let breaknav = JSON.parse(sessionStorage.getItem("breaknav")); - let pathnameBreak = sessionStorage.getItem("pathname2"); - const pathname = window.location.href.lastIndexOf("/"); - const pathnamestr = window.location.href.substr(pathname); + let urlHref=(window.location.href).replace(/^\/|\/$/g, ''); + const pathname = urlHref.lastIndexOf("/"); + const pathnamestr = urlHref.substr(pathname); let breakflag = pathnamestr.includes("add") || pathnamestr.includes("aid") ||