Skip to content

Conversation

@chenjun1011
Copy link
Contributor

@chenjun1011 chenjun1011 commented Feb 7, 2020

解决 MPA 下,希望在 Document 中对不同页面,构建不同信息的问题 #165

改动同时涉及到 rax-document 增加 App

alibaba/rax#1728

使用示例:

import { createElement } from 'rax';
import { Root, Style, Script, App} from 'rax-document';

import appJSON from '../app.json';

function Document() {
  return (
    <App config={appJSON}>
      {
        pageInfo => <html>
          <head>
            <meta charset="utf-8" />
            <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover"/>
            <title>{pageInfo.title}</title>
            <Style />
          </head>
          <body>
            {/* root container */}
            <Root />
            <Script />
          </body>
        </html>
      }
    </App>
  );
}

export default Document;

@fyangstudio
Copy link
Contributor

用户都需要额外配置一个 route.name ?

@chenjun1011
Copy link
Contributor Author

用户都需要额外配置一个 route.name ?

不需要的,这里的对应的 pageName 是 entry 名, route 里 如果配置了 name ,会优先作为 entry name, 这里只是个示例

@yuanyan
Copy link
Contributor

yuanyan commented Feb 7, 2020

为什么不考虑实现一个 <Title> 组件?

@chenjun1011
Copy link
Contributor Author

为什么不考虑实现一个 <Title> 组件?

Title 只能解决 title 的问题,实际需求中,用户可能需要根据不同的页面,渲染不同的 spm meta 信息等等

@chenjun1011 chenjun1011 changed the title feat: pass page name to document feat: pass page info to document Feb 13, 2020
yuanyan
yuanyan previously approved these changes Feb 13, 2020
@chenjun1011 chenjun1011 merged commit cded3b5 into master Feb 19, 2020
@chenjun1011 chenjun1011 deleted the feat-pass-page-info branch February 19, 2020 02:10
@chenjun1011 chenjun1011 mentioned this pull request Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants