ConceptsCatch-all 路由编辑此页面Catch-all 路由用于匹配不符合应用程序中任何其他路由的 URL。这对于显示 404 页面或在用户输入无效 UR L时重定向到特定路由非常有用。 要创建一个 catch-all 路由,请在路由列表末尾放置一个带星号 * 的路径。您可以命名这个参数以访问 URL 未匹配的部分。 import { Router, Route } from "@solidjs/router"; import Home from "./Home";import About from "./About";import NotFound from "./NotFound"; const App = () => ( <Router> <Route path="/home" component={Home} /> <Route path="/about" component={About} /> <Route path="*404" component={NotFound} /> </Router>); 现在,如果用户导航到与 /home 或 /about 不匹配的 URL,将会渲染 NotFound 组件。报告此页面问题上一个← 搜索参数下一个嵌套路由 →