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

server render bundle error, try client render, the server render error ReferenceError: window is not defined #31

Closed
dbsg opened this issue Oct 11, 2017 · 2 comments

Comments

@dbsg
Copy link

dbsg commented Oct 11, 2017

2017-10-11 16:10:54,491 ERROR 3081 [story/story.js] server render bundle error, try client render, the server render error ReferenceError: window is not defined
at VueComponent.data (vue_ssr_bundle:4820:19)
at VueComponent.mergedInstanceDataFn (/Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue/dist/vue.runtime.common.js:1150:21)
at getData (/Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue/dist/vue.runtime.common.js:3228:17)
at initData (/Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue/dist/vue.runtime.common.js:3187:7)
at initState (/Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue/dist/vue.runtime.common.js:3118:5)
at VueComponent.Vue._init (/Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue/dist/vue.runtime.common.js:4289:5)
at new VueComponent (/Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue/dist/vue.runtime.common.js:4461:12)
at vue_ssr_bundle:1735:15
at /Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue-server-renderer/build.js:7803:43
at /Users/dbsg/WebstormProjects/page_8pig_com/node_modules/vue-server-renderer/build.js:7800:14

这个错误的原因是啥啊,还有index.js和layout.html哪个是基本模版啊,首页好像用的是layout,里面的story用的是index.js,,,菜鸟求解答

@ZyJoey
Copy link

ZyJoey commented Oct 12, 2017

服务端渲染失败就会启用前端渲染,错误原因是服务端没有window对象,你看看哪里有用到这个,加个判断 前端环境下执行这块代码就行了~

@dbsg
Copy link
Author

dbsg commented Oct 12, 2017

@ZyJoey 多谢,已经找到原因了,服务器渲染失败,原因是regeneratorRuntime is not defined,安装babel-plugin-transform-runtime之后就可以解决了,https://segmentfault.com/a/1190000009065987

@dbsg dbsg closed this as completed Oct 12, 2017
@dbsg dbsg reopened this Oct 12, 2017
@dbsg dbsg closed this as completed Oct 12, 2017
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