1 回答
TA贡献1864条经验 获得超2个赞
<Route render={({location}) => (
<div>
<Route exact path="/" render={() => (<Redirect to="/roomMain"/>)}/>
<TransitionGroup>
<CSSTransition key={location.key}
timeout={{enter: 500, exit: 300}}
classNames="fade">
<Switch location={location}>
{routes.map((route, index) => {
if (route.protected === 'yes') {
return (
<PrivateRoute location={location}
key={index}
path={route.path}
component={route.component}
exact/>
)
} else {
return (
<Route location={location}
key={index}
path={route.path}
component={route.component}
exact/>
)
}
})}
</Switch>
</CSSTransition>
</TransitionGroup>
</div>
)}/>
添加回答
举报