解决导航重复渲染bug

This commit is contained in:
Apple 2022-08-15 18:10:24 +08:00
parent 50c676d83e
commit 2c855f9f64
2 changed files with 7 additions and 5 deletions

View File

@ -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 (
<div className="mouseMenu" onMouseLeave={this.closeMenuMask.bind(this)} onMouseEnter={this.props.mouseEnter}>
<div className="menuBody">

View File

@ -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") ||