Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update customization layout solutions #642

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/docs/layout.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,18 @@ Tips: When the layout mode is `mix`,click the first menu, page cannot route th

Sometimes we don't want to use the built-in layout and want to do more customization. We also provide flexible customization solutions.

The layout is essentially a special component, and the child pages will be passed to the layout component as attributes. The easyst layout is this:
The layout is essentially a special component, and the child pages will be passed to the layout component as attributes. The easiest layout is this:

```tsx | pure
// Children must be rendered, otherwise the child routes cannot be displayed
// Here you can also set global provision
// if you use umi@3, you can use the following code
// Detail: https://v3.umijs.org/docs/routing#routes
const layout = ({ children }) => children;
export default layout;

// if you use umi@4, you should use the following code
// Detail: https://umijs.org/docs/guides/routes#routes
const Layout = () => <Outlet />;
export default Layout;
```

We create a new BaseLayout.tsx in `src/layouts/`, copy the above code, and add the following code in `config/config.ts`:
Expand Down
10 changes: 8 additions & 2 deletions docs/docs/layout.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,14 @@ export default [
},
];

// src/layout/index.tsx
const Layout = ({ children }) => children;
// 如果使用的是 umi@3 src/layout/index.tsx 应该是这样的
// 具体的实现可以参考:https://v3.umijs.org/zh-CN/docs/routing#routes
const layout = ({ children }) => children;
export default layout;

// 如果使用的是 umi@4 src/layout/index.tsx 应该是这样的
// 具体的实现可以参考:https://umijs.org/docs/guides/routes#routes
const Layout = () => <Outlet />;
export default Layout;
```

Expand Down