Commit c17717fa by zhangleyuan

feat:将main.jsx改成hooks写法

parent 5e30ca6c
import React from 'react' import React , { useContext, useEffect ,useState}from 'react'
import './Main.less'; import './Main.less';
import Bus from "@/core/bus"; import Bus from "@/core/bus";
import { MainRoutes } from '@/routes'; import { MainRoutes } from '@/routes';
class Main extends React.Component { function Main(){
constructor(props) { // constructor(props) {
super(props); // super(props);
this.state = { // this.state = {
menuType: 1, // menuType: 1,
} // }
} // }
componentDidMount() { const [menuType,setMenuType] = useState(1);
console.log("MainRoutes",MainRoutes);
Bus.bind("menuTypeChange", (menuType) => {
this.setState({ menuType })
});
}
render() {
const { hasBanner } = this.props;
return ( return (
<div <div
className={this.state.menuType ? `right-container has-nav ${hasBanner ? 'has_banner' : ''}` : `right-container has-nav right-container-vertical ${hasBanner ? 'has_banner' : ''}`} className={menuType ? `right-container has-nav}` : `right-container has-nav right-container-vertical}`}
id="rightContainer" id="rightContainer"
> >
<MainRoutes/> <MainRoutes/>
</div> </div>
) )
}
} }
export default Main; export default Main;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment