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

一个页面局部服务端渲染,局部浏览器渲染 #36

Closed
yangchongduo opened this issue Apr 6, 2018 · 3 comments
Closed

一个页面局部服务端渲染,局部浏览器渲染 #36

yangchongduo opened this issue Apr 6, 2018 · 3 comments

Comments

@yangchongduo
Copy link

一个页面局部服务端渲染,局部浏览器渲染

下面是ssr的 这样就可以实现浏览器渲染

const DynamicComponentWithNoSSR = dynamic(import('../components/hello3'), {
  ssr: false
})

北斗有提供这样的吗?

@njugray
Copy link
Contributor

njugray commented Apr 8, 2018

没有上述用法
如果只需要客户端渲染, 可以把渲染过程放在 componentDidMount 生命周期之后.

上述的代码看起来是 dynamic import 的用法, 服务端渲染都是同步的. 如果只是语法上的支持, 可以尝试自定义配置babel插件

@yangchongduo
Copy link
Author

如何把渲染 放在 componentDidMount ?
如果 require 一个包 有window 对象就报错,怎么处理?

@njugray
Copy link
Contributor

njugray commented Apr 10, 2018

如何把渲染 放在 componentDidMount ?

把异步操作丢到 componentDidMount 里就可以了.

如果 require 一个包 有window 对象就报错,怎么处理?

北斗里默认加入了BOM的polyfill的, 绝大多数情况下, 代码里使用 window, document等, 是不会报错的, 你可以排查下报错的代码, 如果是 node的 global 没有的变量使用导致报错, 可以自行 polyfill

@njugray njugray closed this as completed Apr 18, 2018
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

No branches or pull requests

2 participants