【问题标题】:Flow Router SSR parameter error流路由器 SSR 参数错误
【发布时间】:2016-09-28 18:23:02
【问题描述】:

我想用我的 SSR Flow Router

获取 url 参数
FlowRouter.route("/:lang", {
  name: "home",
  action({lang}) {
    console.log(lang);
    mount(MainLayout, {
      content: () => (<Home/>)
    });
  }
});

我不知道为什么,但我在路由 http://localhost:3000/testparam 上遇到此错误

Error when doing SSR. path:/testparam: Expected "lang" to be defined

我的带有“testparam”的 console.log 在服务器端控制台上出现 before 错误。


编辑: 在 client 端也会出现错误:

Uncaught TypeError: Expected "lang" to be defined

【问题讨论】:

  • 没有 SSR 也会发生这种情况吗?

标签: meteor flow-router


【解决方案1】:

我认为 {lang} 不正确。试试

action(params) { console.log(params.lang) }

这里是我使用 SSR 路由器的演示示例:

https://github.com/LucaMele/meteor-react-ssr-app-demo/blob/master/lib/routing.js

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-30
    • 1970-01-01
    • 1970-01-01
    • 2016-08-18
    • 2015-12-07
    • 1970-01-01
    • 2016-09-15
    相关资源
    最近更新 更多