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

建議:基於page component的全局layout系統 #832

Closed
MengWeiChen opened this issue Aug 14, 2018 · 3 comments
Closed

建議:基於page component的全局layout系統 #832

MengWeiChen opened this issue Aug 14, 2018 · 3 comments

Comments

@MengWeiChen
Copy link
Contributor

MengWeiChen commented Aug 14, 2018

缘起

目前的umi只有一個全局的layout,用起來比較麻煩一點,建議可以參考Nuxt.js的全局layout方式

注意点

參考Nuxt.js的做法,透過page component中的static property去決定layout,具體的作法可能會像這樣

// pages/login.js
const Login = () => <h1>Login component</h1>;
Login.layout = 'blank'
export default Login

或是

// pages/login.js

export default class Login extends Component {
  static layout = 'blank'

  render() {
    return (<h1>Login component</h1>)
  }
}

目錄結構

+ layouts
  - blank.js
  - default.js

比較要注意的有兩個部分:

  1. HOC 可能會導致router無法順利取得component的layout property
  2. 巢狀route要有後蓋前的全局layout特性

参考

Nuxt.js layout

@MengWeiChen MengWeiChen changed the title 建議:基於page的全局layout系統 建議:基於page component的全局layout系統 Aug 14, 2018
@yutingzhao1991
Copy link
Contributor

或者可以用现在的路由配置的方案: https://github.com/umijs/umi/blob/master/packages/umi-build-dev/src/routes/fixtures/file-config/c/c.js

/*
layout: Blank
title:
  - c
  - d
 */

@wangxingkang
Copy link
Member

比较支持类似nuxt.js类似的实现

@sorrycc sorrycc mentioned this issue Oct 30, 2018
31 tasks
@stale
Copy link

stale bot commented Mar 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the type(wontfix) label Mar 14, 2019
@stale stale bot closed this as completed Mar 21, 2019
sorrycc pushed a commit that referenced this issue Jun 23, 2022
… file (#832)

* fix(bundler-webpack): Fix runtimePublicPath effects assets url in css file

* fix(bundler-webpack): Add test

* fix(bundler-webpack): code format
xierenyuan pushed a commit to xierenyuan/umi that referenced this issue Jun 23, 2022
… file (umijs#832)

* fix(bundler-webpack): Fix runtimePublicPath effects assets url in css file

* fix(bundler-webpack): Add test

* fix(bundler-webpack): code format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants