正常 第一级的 switch 可以实现404的访问
http://localhost:3000/abcd => 404
问题: 第二级,AboutMenu 确不能显示404
http://localhost:3000/about/about3 => 主页 没有显示404
const RouterTest = () => <HashRouter> <div> <Switch> <Route exact path='/' component={Home} /> <Route path='/about' component={AboutMenu} /> <Route path='/test' component={Test} /> <Route component= {Error404}/> </Switch> </div> </HashRouter>
子路由的switch配置
const AboutMenu = () => <div> <Switch> <Route exact path='/about' component={About0} /> <Route exact path='/about/about1' component={About1} /> <Route exact path='/about/about2' component={About2} /> <Route component= {Error404}/> </Switch> </div>
export default AboutMenu;