一般地,首页需要在全局路由的基础上,增加页面路由功能。
因为首页有导航,有页头、页尾这些固定的布局,而内容板块可以随导航而变动。这时候全局路由已经不能满足页面局部刷新的需求。
假设首页架构页面是一个独立组件,并称为父组件,Content内容由各导航所对应的页面组件按需替换加载。则页面内跳转有如下情况。
1、父组件跳转子组件;
2、子组件跳转兄弟组件;
父组件跳转子组件
这个实现简单,只要在父组件的Content区域,用子组件替换即可。父组件代码:contentView = () => {
switch (this.state.infoType) {
case 'dashboard':
console.log('Dashboard')
return
case 'team':
console.log('TeamConfig')
return
case 'project':
console.log('ProjectList')
return
case 'projectDetail':
console.log('ProjectDetail')
return
case 'codeReview':
console.log('Code Review')
return
case 'base':
retu