我知道以前曾经问过这个问题,但没有一个答案适用于我。我有这个基本的路线设置:
import React from 'react'
import { Router, Route, IndexRoute, browserHistory } from 'react-router'
import CoreLayout from 'layouts/CoreLayout/CoreLayout'
import AuthLayout from 'layouts/AuthLayout/AuthLayout'
import HomeView from 'views/Home/HomeView'
import AuthView from 'views/Auth/AuthView'
import SignupView from 'views/Signup/SignupView'
export default ( store ) => (
<Router history={browserHistory}>
<Route path='/' component={CoreLayout}>
<IndexRoute component={HomeView}/>
</Route>
<Route component={AuthLayout}>
<Route path="/signup" component={SignupView} />
<Route path="/auth" component={AuthView} />
</Route>
</Router>
)
我还有一个按钮,当按下该按钮时,应该重定向到另一个页面browserHistory.push( '/signup' )
。单击时,我可以在浏览器中看到URL更新,但组件未安装。知道我在这里做错了什么吗?
根据要求,这是AuthLayout
:
import React, { PropTypes } from 'react'
import 'styles/core.scss'
function AuthLayout( { children } ) {
return (
<div className='page-container'>
{children}
</div>
)
}
AuthLayout.propTypes = {
children: PropTypes.element
};
export default AuthLayout