码迷,mamicode.com
首页 > 其他好文 > 详细

react-router

时间:2020-05-20 12:47:02      阅读:43      评论:0      收藏:0      [点我收藏+]

标签:app   ide   dom   profile   file   怎么   asc   out   const   

import {Provider} from ‘react-redux‘	
import {Router, hashHistory, Route, IndexRoute, Switch} from ‘react-router‘;
import store from ‘redux/store.js‘;  	// redux store
import KYRYComponent from ‘./components/KYRYComponent‘;


const routes = (
  {/* redux 所有组件共用 */}	
  <Provider store={store}>										  
    <Router history={hashHistory}>
		<Route path="/" component={App}>
                {/*3个角色 */}
		<IndexRoute component={KYRYComponent} />       	

		<Route path="cloudProfile" component={CloudOverviewView}/>
		<Route path="*" component={Error}/></Route>
    </Router>
  </Provider>
);

ReactDOM.render(routes, document.getElementById(‘root‘));

import React from ‘react‘;
// import Experimentlist from ‘../StudentComponent/Experimentlist‘;
// import Classmangement from ‘../TeacherComponent/Classmangement‘;
// import CloudOverviewView from ‘../page/CloudOverviewView‘;
// import Myclass from ‘../StudentComponent/Personalcenter/Myclass‘;
import DataCenterOverviewView from ‘../page/DataCenterOverviewView‘;

class KYRYComponent extends React.PureComponent {
	constructor(props){
		super(props);
	}
	render(){
                //如果student 走这个组件 user_type怎么来的
		// if(user_type==‘Student‘) {                    
		// 	return <Myclass />
                //如果Teacher 走这个组件	
		// }else if(user_type==‘Teacher‘){				 
		// 	return <Classmangement />
                //如果Admin 走这个组件	首页走这个	
		// }else{										 		
			return <DataCenterOverviewView />
		// }
	}
}
export default KYRYComponent;

  

react-router

标签:app   ide   dom   profile   file   怎么   asc   out   const   

原文地址:https://www.cnblogs.com/zhanglanzuopin/p/12922627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!