Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cdsf-wx-app
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
cdsf-wx-app
Commits
ac89f7c1
Commit
ac89f7c1
authored
Nov 21, 2018
by
姜雷
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'test'
添加错误捕获页面 See merge request
!28
parents
83edd721
8a0b62be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
27 deletions
+68
-27
ErrorBoundary.js
src/containers/ErrorCatch/ErrorBoundary.js
+37
-0
index.js
src/containers/Repair/index.js
+31
-27
No files found.
src/containers/ErrorCatch/ErrorBoundary.js
0 → 100644
View file @
ac89f7c1
import
React
from
'react'
;
class
ErrorBoundary
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
error
:
null
,
errorInfo
:
null
};
}
componentDidCatch
(
error
,
errorInfo
)
{
// Catch errors in any components below and re-render with error message
this
.
setState
({
error
:
error
,
errorInfo
:
errorInfo
,
});
// You can also log error messages to an error reporting service here
}
render
()
{
if
(
this
.
state
.
errorInfo
)
{
// Error path
return
(
<
div
>
<
h2
>
Something
went
wrong
.
<
/h2
>
<
details
style
=
{{
whiteSpace
:
'pre-wrap'
}}
>
{
this
.
state
.
error
&&
this
.
state
.
error
.
toString
()}
<
br
/>
{
this
.
state
.
errorInfo
.
componentStack
}
<
/details
>
<
/div
>
);
}
// Normally, just render children
return
this
.
props
.
children
;
}
}
export
default
ErrorBoundary
;
src/containers/Repair/index.js
View file @
ac89f7c1
...
@@ -3,6 +3,8 @@ import { Switch, Route, Redirect, NavLink } from 'react-router-dom';
...
@@ -3,6 +3,8 @@ import { Switch, Route, Redirect, NavLink } from 'react-router-dom';
import
styles
from
'./style.css'
;
import
styles
from
'./style.css'
;
import
ReprtRepair
from
'./ReprtRepair'
;
import
ReprtRepair
from
'./ReprtRepair'
;
import
RepairList
from
'./RepairList'
;
import
RepairList
from
'./RepairList'
;
import
ErrorBoundary
from
'../ErrorCatch/ErrorBoundary'
;
class
index
extends
Component
{
class
index
extends
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
...
@@ -30,34 +32,36 @@ class index extends Component {
...
@@ -30,34 +32,36 @@ class index extends Component {
render
()
{
render
()
{
const
{
showFooter
}
=
this
.
state
;
const
{
showFooter
}
=
this
.
state
;
return
(
return
(
<
div
className
=
"Content-Wrap"
>
<
ErrorBoundary
>
<
div
className
=
"RepairContent"
>
<
div
className
=
"Content-Wrap"
>
<
Switch
>
<
div
className
=
"RepairContent"
>
<
Route
path
=
"/repair/ReprtRepair"
component
=
{
ReprtRepair
}
/
>
<
Switch
>
<
Route
path
=
"/repair/RepairList"
component
=
{
RepairList
}
/
>
<
Route
path
=
"/repair/ReprtRepair"
component
=
{
ReprtRepair
}
/
>
<
Route
render
=
{()
=>
<
Redirect
to
=
"/repair/ReprtRepair"
/>
}
/
>
<
Route
path
=
"/repair/RepairList"
component
=
{
RepairList
}
/
>
<
/Switch
>
<
Route
render
=
{()
=>
<
Redirect
to
=
"/repair/ReprtRepair"
/>
}
/
>
<
/div
>
<
/Switch
>
{
showFooter
&&
(
<
div
className
=
{
styles
.
footer
}
>
<
NavLink
className
=
{
styles
[
'footer-item'
]}
to
=
"/repair/ReprtRepair"
replace
>
报修服务
<
/NavLink
>
<
span
className
=
{
styles
.
line
}
/
>
<
NavLink
className
=
{
styles
[
'footer-item'
]}
to
=
"/repair/RepairList"
replace
>
报修记录
<
/NavLink
>
<
/div
>
<
/div
>
)}
{
showFooter
&&
(
<
/div
>
<
div
className
=
{
styles
.
footer
}
>
<
NavLink
className
=
{
styles
[
'footer-item'
]}
to
=
"/repair/ReprtRepair"
replace
>
报修服务
<
/NavLink
>
<
span
className
=
{
styles
.
line
}
/
>
<
NavLink
className
=
{
styles
[
'footer-item'
]}
to
=
"/repair/RepairList"
replace
>
报修记录
<
/NavLink
>
<
/div
>
)}
<
/div
>
<
/ErrorBoundary
>
);
);
}
}
}
}
...
...
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