铁路由器:未找到路由定义

时间:2018-06-12 11:35:46

标签: meteor iron-router

我正在开发一个基本的meteorjs应用程序,并使用铁路由器进行客户端路由。我设置了我的路线,出版物和模式,但我不能让铁路由器运行。在我启动我的应用程序后,它始终显示“找不到路由定义”。我的router.js在/ lib中。改变它的位置根本不起作用。我没有任何控制台日志。任何帮助表示赞赏。

我的router.js:

Router.route('/', {
  name: 'main',
  layoutTemplate: 'mainLay',
  waitOn: function() {
    return Meteor.subscribe('posts');
 },
  action: function() {
    this.render('allPosts');
}
 });

 Router.route('/create-post', {
  name: 'createPost',
  layoutTemplate: 'mainLay',
  action: function() {
    if (Meteor.userId()) {
      this.render('createPost');
    }
    else {
    Router.go('/');
   }
  }
 });

Router.route('/post/:postId', {
 name: 'post',
 layoutTemplate: 'mainLay',
 waitOn: function() {
  return [
    Meteor.subscribe('comments', this.params.postId),
    Meteor.subscribe('post', this.params.postId)
  ];
},
action: function() {
  var postId = this.params.postId;
  this.render('postDetail');
}
});

在我的.meteor / packages中我有条目:

iron:router

1 个答案:

答案 0 :(得分:0)

如果您不清楚应用程序结构,那可能会有所帮助: https://guide.meteor.com/structure.html#example-app-structure

无法找到铁路由器

的模板
  

客户端入口点不知道router.js:/client/main.js

client/
  main.js                      # client entry point, imports all client code

在您目前的案例中:

  main.js内的

检查是否添加:

     

import'/lib/router.js';

相关问题