zhangyuang / egg-react-ssr

最小而美的Egg + React + SSR 服务端渲染应用骨架,同时支持JS和TS
http://doc.ssr-fc.com/
MIT License
1.91k stars 211 forks source link

client端需要获取url上的参数数据id,用到location.pathname,但server端不能解析window,怎么解决? #181

Closed serenaxx closed 4 years ago

serenaxx commented 4 years ago

报错: nodejs.ReferenceError: location is not defined, 在component里怎么获取route上params?

zhangyuang commented 4 years ago

服务端参考egg文档使用ctx.req.params.xxx ctx.req.xxx

serenaxx commented 4 years ago

我在entry.js里把ctx.req.url 传给了ActiveComponent,已解决