鍍金池/ 問答/HTML/ react 組件依賴路由的核心思想是什么

react 組件依賴路由的核心思想是什么

發(fā)現(xiàn)我的組件不依賴路由,在頁面刷新后,只顯示單個組件而沒有父級組件呢

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文件中就是這么定義的。

2018年1月16日 00:30