Kadira Flow Router"路径没有路径:/"

时间:2018-01-15 03:56:11

标签: javascript node.js meteor routing flow-router

我有一个流星应用程序,结构如下:

client
--main.js
imports
 \startup
   \client
    --index.js
    --routes.js
 \ui
   \pages
    --home-page.html
    --home-page.js
    --login-page.html
    --login-page.js
   \layouts
    --app-layout.html
    --app-layout.js

Js和Html文件导入\ ui具有有效的html页面和逻辑。 所以现在我想手动设置路由,根据官方的流星网站,我已经改变了main.js如下:

import '/imports/startup/client';

我在import \ startup \ client中的index.js只包含routes.js:

import './routes.js';

和routes.js:

import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';

import '../../ui/pages/login-page.js';
import '../../ui/layouts/app-layout.js'
import '../../ui/pages/home-page.js'

FlowRouter.route('/', {
    name: 'Main.login',

        triggersEnter: [function(context, redirect) {
            if (Meteor.userId()) {
                redirect('/home');
            }
        }],
    action() {
        BlazeLayout.render('Login_Page');

    }
});
FlowRouter.route('/home', {
    name: 'Main.home',
    triggersEnter: [function(context, redirect) {
        if (!Meteor.userId()) {
            redirect('/');
        }
    }],
    action() {
        BlazeLayout.render('App_Layout', { body : 'HomePage' });

    }
});

当我从我的项目目录运行meteor,并访问url:3000时,没有显示任何内容,我在浏览器的javascript控制台中看到:

There is no route for the path: /
kadira_flow-router.js:517:5
router.js/Router.prototype._notfoundRoute
http://host:3000/packages/kadira_flow-router.js:517:5
router.js/Router.prototype._updateCallbacks/<
http://host:3000/packages/kadira_flow-router.js:705:5
index.js/Route.prototype.middleware/<
http://host:3000/packages/kadira_flow-router.js:1488:52

流星版本为METEOR@1.6.0.1 我不明白,我已经在官方网站上做了所有的例子,但仍然无法通过这种方式进行路由。看起来main.js甚至不包括routes.js。

这是我的项目包清单:

accounts-password      1.5.0  Password support for accounts
accounts-ui            1.2.0  Simple templates to add login widgets to an app
blaze-html-templates   1.1.2  Compile HTML templates into reactive UI with Meteor Blaze
dynamic-import         0.2.1  Runtime support for Meteor 1.5 dynamic import(...) syntax
ecmascript             0.9.0  Compiler plugin that supports ES2015+ in all .js files
es5-shim               4.6.15  Shims and polyfills to improve ECMAScript 5 support
jquery                 1.11.10  Manipulate the DOM using CSS selectors
kadira:blaze-layout    2.3.0  Layout Manager for Blaze (works well with FlowRouter)
kadira:flow-router     2.12.1  Carefully Designed Client Side Router for Meteor
meteor-base            1.2.0  Packages that every Meteor app needs
mobile-experience      1.0.5  Packages for a great mobile user experience
mongo                  1.3.1  Adaptor for using MongoDB and Minimongo over DDP
ostrio:meteor-root     1.0.6  [Server] Get current path on server, where is Meteor application is running
practicalmeteor:mocha  2.4.5_6  Write package tests with mocha and run them in the browser or from the command line with spac...
reactive-dict          1.2.0  Reactive dictionary
reactive-var           1.0.11  Reactive variable
sacha:spin             2.3.1  Simple spinner package for Meteor
shell-server           0.3.1  Server-side component of the `meteor shell` command.
standard-minifier-css  1.3.5  Standard css minifier used with Meteor apps by default.
standard-minifier-js   2.2.3  Standard javascript minifiers used with Meteor apps by default.
tracker                1.1.3  Dependency tracker to allow reactive callbacks
vsivsi:job-collection  1.5.2  A persistent and reactive job queue for Meteor, supporting distributed workers that can run any...

2 个答案:

答案 0 :(得分:0)

我想你忘了导入html。

答案 1 :(得分:0)

我通过删除package.json中的“流星”道具解决了我的问题:

  "meteor": {
    "mainModule": {
      "client": "client/main.js",
      "server": "server/main.js"
    },
    "testModule": "tests/main.js"
  }

在我删除它并为我的路由添加一个名称(您已经拥有)后,我的FlowRouter可以正常工作。