<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={Home} />
<Route path=":category" component={Category} />
<Route path="*" component={NotFound} />
</Route>
</ROuter>
比如传入了一个不存在的category
,如何判断,并转到404模块?
什么叫“不存在的
category
” ?意思是代码已经进入了
Category
组件,但发现这个:category
不符合条件?如果是这样的话,那直接
return
那个Notfound
视图好了,像这样: