Skip to content

Commit 0a559ce

Browse files
add example
1 parent 713c4ee commit 0a559ce

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/app/pages/Dynamic/:para.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { useParams } from "react-router";
2+
3+
export default function Index() {
4+
const p = useParams();
5+
6+
return <div>dynamic {JSON.stringify(p)}</div>;
7+
}

src/app/pages/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default function Index() {
1212
<Button onClick={() => navigate("/Foo")}>goto foo</Button>
1313
<Button onClick={() => navigate("/Bar")}>goto bar</Button>
1414
<Button onClick={() => navigate("/Baz")}>goto baz</Button>
15+
<Button onClick={() => navigate(`/Dynamic/${Math.random().toString().slice(2)}`)}>goto dynamic</Button>
1516
<Button onClick={() => navigate("/I18n")}>goto i18n</Button>
1617
<Button onClick={() => navigate("/HHH")}>404 page</Button>
1718
</>

src/app/router/dynamicRoutes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/* do not editor this template */
33
import type { DynamicRouteConfig } from "@app/types/router";
44

5-
export const dynamicRouteConfig: DynamicRouteConfig[] = [{"path":"/Bar","componentPath":"Bar"},{"path":"/Baz","componentPath":"Baz"},{"path":"/Foo","componentPath":"Foo"},{"path":"/I18n","componentPath":"I18n"},{"path":"/","componentPath":"index"},{"path":"/*","componentPath":"404"}];
5+
export const dynamicRouteConfig: DynamicRouteConfig[] = [{"path":"/Bar","componentPath":"Bar"},{"path":"/Baz","componentPath":"Baz"},{"path":"/Foo","componentPath":"Foo"},{"path":"/I18n","componentPath":"I18n"},{"path":"/","componentPath":"index"},{"path":"/Dynamic/:para","componentPath":"Dynamic/:para"},{"path":"/*","componentPath":"404"}];

0 commit comments

Comments
 (0)