【发布时间】:2017-06-27 04:01:31
【问题描述】:
这是我的代码:
class noMatch extends React.Component {
render() {
return 'Not Found'
}
}
ReactDOM.render(
<BrowserRouter>
<Switch>
<Route exact path='/(index.html)?' component={App}/>
<Route component={noMatch}/>
</Switch>
</BrowserRouter>,
mountNode
);
应用程序按预期在 localhost:3000/ 和 localhost:3000/index.html 中运行。但是当没有匹配时,我的 no Match 不会渲染?我正在关注文档here 中的 noMatch 教程。帮忙?
【问题讨论】:
-
检查重复问题,答案将帮助您理解您的错误。如果您仍然无法解决问题,请告诉我
-
我将我的 NoMatch 组件大写,但它仍然不起作用。
-
控制台中的任何错误
-
只是没有找到 404。但我期待 NoMatch 组件呈现
标签: reactjs react-router react-router-v4 react-router-dom