From 2c855f9f64f9df7452cd89be49f01f6272cbeba7 Mon Sep 17 00:00:00 2001 From: Apple <> Date: Mon, 15 Aug 2022 18:10:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AF=BC=E8=88=AA=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=B8=B2=E6=9F=93bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/mouseMenu/main.js | 6 ++++-- src/components/subnav/main.js | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) 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") ||