Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example(user-dashboard): migrate to dva@2
- Loading branch information
Showing
5 changed files
with
30 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
] | ||
} | ||
}, | ||
"dllPlugin": { | ||
"xdllPlugin": { | ||
"exclude": [ | ||
"babel-runtime" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,29 @@ | ||
import React from 'react'; | ||
import { Router } from 'dva/router'; | ||
|
||
const cached = {}; | ||
function registerModel(app, model) { | ||
if (!cached[model.namespace]) { | ||
app.model(model); | ||
cached[model.namespace] = 1; | ||
} | ||
} | ||
import { Router, Switch, Route } from 'dva/router'; | ||
import dynamic from 'dva/dynamic'; | ||
|
||
function RouterConfig({ history, app }) { | ||
const routes = [ | ||
{ | ||
path: '/', | ||
name: 'IndexPage', | ||
getComponent(nextState, cb) { | ||
require.ensure([], (require) => { | ||
cb(null, require('./routes/IndexPage')); | ||
}); | ||
}, | ||
}, | ||
{ | ||
path: '/users', | ||
name: 'UsersPage', | ||
getComponent(nextState, cb) { | ||
require.ensure([], (require) => { | ||
registerModel(app, require('./models/users')); | ||
cb(null, require('./routes/Users')); | ||
}); | ||
}, | ||
}, | ||
]; | ||
const IndexPage = dynamic({ | ||
app, | ||
component: import('./routes/IndexPage'), | ||
}); | ||
|
||
const Users = dynamic({ | ||
app, | ||
models: [ | ||
import('./models/users'), | ||
], | ||
component: import('./routes/Users'), | ||
}); | ||
|
||
return <Router history={history} routes={routes} />; | ||
return ( | ||
<Router history={history}> | ||
<Switch> | ||
<Route exact path="/" component={IndexPage} /> | ||
<Route exact path="/users" component={Users} /> | ||
</Switch> | ||
</Router> | ||
); | ||
} | ||
|
||
export default RouterConfig; |
2 comments
on commit eef1bcf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
browser.js?87e2:40Uncaught Error: You have provided a history object created with history v4.x or v2.x and earlier. This version of React Router is only compatible with v3 history objects. Please change to history v3.x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"dependencies": {
"antd": "^2.6.4",
"babel-runtime": "^6.22.0",
"dva": "^2.0.0-0",
"dva-loading": "^0.2.0",
"query-string": "^5.0.0",
"react": "^16.1.1",
"react-dom": "^16.1.1"
}
2.0.0-0 啥意思,是笔误还是另有玄机~~