import React from 'react';
import ReactDOM from 'react-dom';
import {
BrowserRouter,
Route,
Link,
Switch
} from 'react-router-dom';
import uuid from 'uuid';
const stuData = {
stuList:[
{id:uuid(), name:'张三', sex:'男', tel:'15678904397'},
{id:uuid(), name:'李四', sex:'男', tel:'1567454397'},
{id:uuid(), name:'王五', sex:'女', tel:'13478904397'},
{id:uuid(), name:'王博', sex:'男', tel:'18678904397'},
{id:uuid(), name:'丁一宁', sex:'女', tel:'18778904397'},
{id:uuid(), name:'武宁', sex:'女', tel:'456543343'},
{id:uuid(), name:'汪洋', sex:'女', tel:'12313213132'}
]
}
const Home = () =>(
我是主页
);
const About = () =>(
关于我们
);
/* const StuInfo = (props) =>{ //展示学生详情
let {id} = props.match.params;
let stuInfo = stuData.stuList.find((item)=>{
return item.id === id;
});
if(!stuInfo){
props.history.push('/stu');
return null;
}
return (
学生编号: {stuInfo.id}
学生名字: {stuInfo.name}
学生性别: {stuInfo.sex}
学生电话: {stuInfo.tel}
)
} */
class StuInfo extends React.Component{
render(){
let {id} = this.props.match.params;
let stuInfo = stuData.stuList.find((item)=>{
return item.id === id;
});
if(!stuInfo){
this.props.history.push('/stu');
return null;
}
return (
学生编号: {stuInfo.id}
学生名字: {stuInfo.name}
学生性别: {stuInfo.sex}
学生电话: {stuInfo.tel}
)
}
}
const StuMain = () => (
{
stuData.stuList.map((item,index)=>
-
{item.name}
)
}
);
const Stu = () =>(
)
const Main = () =>(
);
const Header = () =>(
)
class App extends React.Component{
render(){
return (
)
}
}
ReactDOM.render(
, document.getElementById('root'));