以前,我将所有路由放在一个文件中,就像这样
const rootRoute = {
childRoutes: [{
path: '/',
component: require('./containers/App'),
childRoutes: [
require('./routes/app'),
require('./routes/404'),
]
}]
}
render(
<Provider store={store}>
<Router
onUpdate={scrollToTop}
history={history}
routes={rootRoute}
/>
</Provider>,
document.getElementById('app-container')
)
但现在,我使用dynamic routing,并将代码分开
/
我的问题是,我现在怎样才能将/app/dashboard
转移到*
?
此外,像以前一样将所有其他网页/404
重定向到html, body, #fullheight {
min-height:10%;
display: table;
}
body {
background: red;
}
#fullheight {
width: 250px;
background: blue;
}
listen , height:100% is not realy true! you can use height:auto or use px em
?
非常感谢!
答案 0 :(得分:2)
您必须使用 onEnter 事件
应该是这样的:
const rootRoute = {
path: '/',
component: require('./containers/App'),
indexRoute: { onEnter: (nextState, replace) => replace('/app/dashboard') },
childRoutes: [
require('./routes/app'),
require('./routes/404'),
]
}