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

看到了您的SSR例子,发现有个问题 #303

Closed
a573367014 opened this issue Nov 21, 2016 · 15 comments
Closed

看到了您的SSR例子,发现有个问题 #303

a573367014 opened this issue Nov 21, 2016 · 15 comments

Comments

@a573367014
Copy link

看到你上面这个例子 https://github.com/sorrycc/dva-boilerplate-isomorphic, "/about" 渲染的还是“/”的html; 就是说不管路由跳到哪只能服务端渲染根路由

@sorrycc
Copy link
Member

sorrycc commented Nov 21, 2016

问题在哪里? SSR 好像都这么操作的,渲染相同的内容,然后由 JavaScript 决定是由哪个 Component 来渲染。

@a573367014
Copy link
Author

这样导致有时候,js还没运行,显示的是服务端渲染出来的Component ,然后在跳转到相应路由的Component ,会闪烁一下

@sorrycc
Copy link
Member

sorrycc commented Nov 21, 2016

@a573367014
Copy link
Author

同构,你可以试一下代码,我这边是有这个问题的,不同路由服务端也只能渲染根路由组件

@sorrycc
Copy link
Member

sorrycc commented Nov 21, 2016

ok,我找时间试试。

@a573367014
Copy link
Author

好的,谢谢解惑

@a573367014
Copy link
Author

a573367014 commented Nov 22, 2016

我是这么测的,这边console出来都是 “/”路径的代码,希望有时间一定要试下,实例的代码都没动过,就改了一行 console。 (因为怕你不懂我问的什么,所以啰嗦一下,劳烦大神了)

function renderFullPage(html, initialState) {
    return `
 < !DOCTYPE html > 
<html > 
< head >< meta charset = "utf-8" / >< link rel = "stylesheet"href = "/static/index.css" /  >< /head >
< body >
  < div id="root" >
    < div >
      ${html}
    < /div > 
 < /div >

  < script >
    console.log('${html}');
    window.__INITIAL_STATE__ = ${JSON.stringify(initialState)};
  < /script > 

<script src = "/static/index.js" > </script>
< /body > 
< /html >
`
}

@a573367014
Copy link
Author

大神这个问题能目前能解决吗,着急用。。。

@sorrycc
Copy link
Member

sorrycc commented Nov 24, 2016

抱歉,在外开会,要下周才能看了。。

@sorrycc
Copy link
Member

sorrycc commented Nov 26, 2016

已找到问题并在本地解决,还需想 dva 层的 API 如何加,下周修复。

@a573367014
Copy link
Author

好的,3q

@cllgeek
Copy link

cllgeek commented Dec 1, 2016

试了一下,是会出现这个问题,现在修复了吗

@HengCC
Copy link

HengCC commented Dec 2, 2016

同问. 我也发现这个问题了.

@sorrycc
Copy link
Member

sorrycc commented Dec 5, 2016

已修复,改动见这个 Commit 。sorrycc/dva-boilerplate-isomorphic@149e9a7

@chengnuo
Copy link

有没有egg2.0+dva2.0同构的打算?

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

5 participants