以下代码有效但不允许我通过路由将auth对象传递给authService。
const routes = {
path: '/',
indexRoute: { onEnter: (nextState, replace) => replace('/home') } ,
childRoutes: [
{
onEnter: requireAuth,
childRoutes: [
require('./routes/home').default,
]
},
require('./routes/auth').default,
]
};
ReactDOM.render((
<Provider store={store}>
<Router
history={history}
routes={routes}
/>
</Provider>
), document.getElementById('smartadmin-root'));
但是,下面的标准方法不会显示我的登录表单。
ReactDOM.render((
<Provider store={store}>
<Router>
<Route path="/" component={App}>
<indexRoute onEnter={(nextState, replace) => replace('/home')} />
<Route component={Home} onEnter={requireAuth}/>
</Route>
<Route path="login" component={Login}/>
</Router>
</Provider>
), document.getElementById('smartadmin-root'));
我错过了什么?