解决导航重复渲染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() { render() {
let menuList = this.state.activeMenuList;//路由表 let menuList = this.state.activeMenuList;//路由表
const pathname = window.location.href.lastIndexOf('\/'); let urlHref=(window.location.href).replace(/^\/|\/$/g, '');
const pathnamestr = window.location.href.substr(pathname); const pathname = urlHref.lastIndexOf("/");
const pathnamestr = urlHref.substr(pathname);
return ( return (
<div className="mouseMenu" onMouseLeave={this.closeMenuMask.bind(this)} onMouseEnter={this.props.mouseEnter}> <div className="mouseMenu" onMouseLeave={this.closeMenuMask.bind(this)} onMouseEnter={this.props.mouseEnter}>
<div className="menuBody"> <div className="menuBody">

View File

@ -83,9 +83,9 @@ export default class topNav extends React.Component {
let history0 = window.history.length <= 1; let history0 = window.history.length <= 1;
let routeflag = sessionStorage.getItem("showflag"); let routeflag = sessionStorage.getItem("showflag");
let breaknav = JSON.parse(sessionStorage.getItem("breaknav")); let breaknav = JSON.parse(sessionStorage.getItem("breaknav"));
let pathnameBreak = sessionStorage.getItem("pathname2"); let urlHref=(window.location.href).replace(/^\/|\/$/g, '');
const pathname = window.location.href.lastIndexOf("/"); const pathname = urlHref.lastIndexOf("/");
const pathnamestr = window.location.href.substr(pathname); const pathnamestr = urlHref.substr(pathname);
let breakflag = let breakflag =
pathnamestr.includes("add") || pathnamestr.includes("add") ||
pathnamestr.includes("aid") || pathnamestr.includes("aid") ||