发现我的组件不依赖路由,在页面刷新后,只显示单个组件而没有父级组件呢
function RouterConfig({ history }) {
return(
<Router history={history}>
<Switch>
<Route exact path="/" component={lsPage}/>
<Route exact path="/layout" component={layout} />
<Route exact path="/404" component={notFound}/>
<Route exact path="/login" component={loginPage} />
<Route exact path="/sign" component={signUpPage} />
<Route exact path="/personal" component={personPage} />
<Route exact path="/find" component={findPage} />
<Route exact path="/mood" component={moodPage} />
<Route exact path='/display' component={displayPage}/>
<Route exact path='/userset' component={setPage}/>
<Route exact path='/pwdchange' component={pwdchangePage}/>
</Switch>
</Router>
)
}
export default RouterConfig;
render(){
return(
<div className={style.wrap}>
<Router>
<Layout style={{height:'100%',padding: '24px 0'}}>
<Header className={style.header}>
</Header>
<Content style={{ padding: '0 50px',minHeight: 480 }}>
<div className={style.leftSide}>
<Personal/>
<Nav/>
</div>
<div className={style.rightSide}>
<Route path='/layout' exact component={welcomeP}/>
<Route path='/personal' component={personal}/>
<Route path='/find' component={find}/>
<Route path='/mood' component={mood}/>
<Route path='/display' component={display}/>
<Route path='/userset' component={userset}/>
<Route path='/pwdchange' component={pwdchange}/>
</div>
</Content>
<Footer style={{ textAlign: 'center',padding:'0'}}>
<p>
<a className={style.me} onClick={this.handleExit}>退出登录</a>
</p>
</Footer>
</Layout>
</Router>
</div>
)
}
页面刷新后,url localhost:8000/display 页面就只有display的组件,其他的都没有了,请问大大,错在哪里呀
你在
RouterConfig
文件中就是这么定义的。