Skip to content

Commit

Permalink
doc:update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
SunLxy committed May 2, 2023
1 parent 8a904ed commit 73ebf01
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions packages/plugin/router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface RouterPluginProps {

- `routes` 路由`path="/"`路由下的子集路由集合。

```ts
```tsx
import { KktproPageProps } from '@kkt/pro';

const Page = (props: KktproPageProps) => {
Expand All @@ -70,7 +70,7 @@ export default Page;

页面中可直接通过 `navigate` 跳转, 或者通过`react-router-dom`提供的 `useNavigate`来跳转。

```ts
```tsx
import { KktproPageProps, useNavigate } from '@kkt/pro';

const Page = (props: KktproPageProps) => {
Expand All @@ -86,6 +86,29 @@ const Page = (props: KktproPageProps) => {
export default Page;
```

## 支持页面导出`react-router 6`配置参数

```tsx
// 路由加载文件 src/pages/about/index.tsx
const Index = ()=>{
return <div>导出element</div>
}
export default Index;
export const element = <Index />;
export const loader = ()=>{}
export const action = ()=>{}
const ErrorElement = ()=><div>errorElement</div>
export const errorElement =<ErrorElement />
export const lazy=()=>import("@/about")
export const path="/about"
export const shouldRevalidate=({ currentUrl }) => {
// only revalidate if the submission originates from
// the `/meal-plans/new` route.
return currentUrl.pathname === "/meal-plans/new";
}

```

## `kktp`配置文件

```ts
Expand Down

0 comments on commit 73ebf01

Please sign in to comment.