Umi 統一登錄校驗組件


 

 

一、使用umi的routes配置子路由,加載子組件的時候,會加載父組件。將登錄邏輯寫到父組件進行統一處理

config.js代碼片段

routes: [
    {
      path: '/',
      component: '../pages/index', //父組件
      routes: [
        {
          path: '/',
          component: '../pages/CommonHome', //子組件
        },
]}]

 

父組件代碼片段

     <Provider store={appStore}>
        <ConfigProvider locale={zhCN}>
          <PersistGate persistor={persistor}>
            {this.state && this.state.user_info ? this.props.children : <Spin tip="登錄中..."/>}  //登錄成功后設置user_info
          </PersistGate>
        </ConfigProvider>
      </Provider>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM