Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
c17717fa
Commit
c17717fa
authored
Dec 09, 2020
by
zhangleyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:将main.jsx改成hooks写法
parent
5e30ca6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
25 deletions
+18
-25
src/modules/root/Main.jsx
+18
-25
No files found.
src/modules/root/Main.jsx
View file @
c17717fa
import
React
from
'react'
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
import
'./Main.less'
;
import
Bus
from
"@/core/bus"
;
import
{
MainRoutes
}
from
'@/routes'
;
class
Main
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
menuType
:
1
,
}
}
componentDidMount
()
{
console
.
log
(
"MainRoutes"
,
MainRoutes
);
Bus
.
bind
(
"menuTypeChange"
,
(
menuType
)
=>
{
this
.
setState
({
menuType
})
});
}
render
()
{
const
{
hasBanner
}
=
this
.
props
;
return
(
<
div
className=
{
this
.
state
.
menuType
?
`right-container has-nav ${hasBanner ? 'has_banner' : ''}`
:
`right-container has-nav right-container-vertical ${hasBanner ? 'has_banner' : ''}`
}
id=
"rightContainer"
>
<
MainRoutes
/>
</
div
>
)
}
function
Main
(){
// constructor(props) {
// super(props);
// this.state = {
// menuType: 1,
// }
// }
const
[
menuType
,
setMenuType
]
=
useState
(
1
);
return
(
<
div
className=
{
menuType
?
`right-container has-nav
}
`
:
`
right
-
container
has
-
nav
right
-
container
-
vertical
}`}
id=
"rightContainer"
>
<
MainRoutes
/>
</
div
>
)
}
export
default
Main
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment