Commit 3724e420 by 万亚飞

配置优化

parent df17ed68
import React from 'react'; import React, { Suspense, lazy } from 'react';
import { withRouter, NavLink, Switch, Route, Redirect } from 'react-router-dom'; import { withRouter, NavLink, Switch, Route, Redirect } from 'react-router-dom';
import Home from './pages/home'; import Home from './pages/home';
import JobList from './pages/user/JobList'; const JobList = lazy(() => import('./pages/user/JobList'));
import AddMaterial from './pages/user/addMaterial'; const AddMaterial = lazy(() => import('./pages/user/addMaterial'));
import TrainList from './pages/user/TrainList'; const TrainList = lazy(() => import('./pages/user/TrainList'));
import Train from './pages/user/Train'; const Train = lazy(() => import('./pages/user/Train'));
import Pay from './pages/pay/pay';
import NotFind from './pages/404'; import NotFind from './pages/404';
import storage from '@/utils/storage.plugin'; import storage from '@/utils/storage.plugin';
import vc from '@/utils/vconsole'; import vc from '@/utils/vconsole';
//第二页,分类模块的文件使用react-loadable按需加载并且代码分割 //第二页,分类模块的文件使用react-loadable按需加载并且代码分割
class App extends React.Component { class App extends React.Component {
constructor(props) { constructor(props) {
...@@ -52,6 +52,7 @@ class App extends React.Component { ...@@ -52,6 +52,7 @@ class App extends React.Component {
return ( return (
<div className="container"> <div className="container">
<div className="page-content"> <div className="page-content">
<Suspense fallback={<div />}>
<Switch> <Switch>
<Route path="/user/job/add" key="add-job" component={AddMaterial} /> <Route path="/user/job/add" key="add-job" component={AddMaterial} />
<Route path="/user/job/:id" key="edit-job" component={AddMaterial} /> <Route path="/user/job/:id" key="edit-job" component={AddMaterial} />
...@@ -59,9 +60,9 @@ class App extends React.Component { ...@@ -59,9 +60,9 @@ class App extends React.Component {
<Route path="/user/train/add" key="add-train" component={Train} /> <Route path="/user/train/add" key="add-train" component={Train} />
<Route path="/user/train/:id" key="edit-train" component={Train} /> <Route path="/user/train/:id" key="edit-train" component={Train} />
<Route path="/user/train" component={TrainList} /> <Route path="/user/train" component={TrainList} />
<Route path="/pay" component={Pay} />
<Route component={JobList} /> <Route component={JobList} />
</Switch> </Switch>
</Suspense>
</div> </div>
</div> </div>
); );
......
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