跳到正文

Router

将 QuickGUI 核心路由投影到 QuickGUI UI,支持嵌套布局和容量受限的内存历史。

正在加载交互演示…

#导入

从 @quickgui/solid 导入 Router。

import { Router } from "@quickgui/solid";

#用法

<Router initialPath="/">
  <Route path="/" component={Shell}>
    <Route path="/" component={Home} />
    <Route path="/projects/:id" component={Project} />
  </Route>
</Router>

#结构

  • Router
  • Route
  • Link
  • Outlet
<Router>
  <Route path="/" component={AppShell}>
    <Route path="/projects/:id" component={Project} />
  </Route>
  <Link href="/projects/quickgui">Open project</Link>
  <Outlet />
</Router>

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

Router(props: RouterProps): JSX.Element
initialPathstring—

Initial memory-history destination. Defaults to `/`.

string
查看源码
fallbackJSX.Element—

Rendered when no declared route matches.

JSX.Element
查看源码
childrenJSX.Element—

Declares children (optional). Reactive JSX expressions update this property in place.

JSX.Element
查看源码