【问题标题】:Ironrouter says route doesn't exist when it does ("Oops, looks like there's no route on the client")Ironrouter 说路由不存在(“糟糕,客户端上似乎没有路由”)
【发布时间】:2016-06-13 13:20:44
【问题描述】:

我正在尝试在 Meteor 中显示带有参数的 URL,如下所示:

    http://localhost:3000/test/123

我的 routes.js 包含以下内容:

    Router.route('/test/:x1', function () {
      this.render('test', {
        to:"main",
        param:this.params.x1
      });
    });

和main.html下面的模板

   <template name="test">
     <h2>Test {{param}}</h2>
   </template>

但是,当我访问 http://localhost:3000/test/123 时,我收到以下错误消息:

   Oops, looks like there's no route on the client or the server for url:     
   "http://localhost:3000/test/123."

我已经从 Ironrouter 文档中逐字复制了这个内容。 Stackoverflow 的其他问题,例如 Meteor deploy Iron:Router "oops looks like there's no route on the client or the server for url" 似乎并没有完全解决这个问题

【问题讨论】:

  • 我假设您使用的是 Meteor 1.3。您是否在客户端的 main.js 文件中添加了路由文件?
  • 这很奇怪。我复制了你的代码,它可以工作。您将routes.js 文件放在哪个目录中?
  • Faysal:不,只是将 routes.js 添加到客户端目录。是否应该使用 import './routes.js' 在 main.js 中导入;陈述?我试过了,但并没有改变。
  • Tdm:Routes.js 在客户端目录中。它是 Meteor 1.3.2.4

标签: meteor iron-router


【解决方案1】:

所以我以一种有点不确定的方式解决了这个问题。正如其中一位评论者所指出的那样,代码本身可以工作,但在我的应用程序中却不行。所以我创建了一个新应用程序并将代码逐行传输到新应用程序,它继续工作。上面并不是所有的代码都显示出来了,但是省略的部分应该不会影响这个问题。我仍然不知道最初是什么引发了这个问题。

【讨论】:

    猜你喜欢
    • 2016-11-23
    • 2018-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-05
    相关资源
    最近更新 更多