简体   繁体   中英

How to use FlowRouter with Meteor 1.3.1 and “Import”

I'm trying to add a few simple routes to my Meteor app, it's my first time playing with FlowRouter. I installed with:

meteor add kadira:flow-router
meteor add kadira:blaze-layout

Then, I created a lib/routes.js file, containing this:

import '../imports/ui/body.js';

FlowRouter.route('/', {
  name: 'home',
  action: function(params) {
    console.log("home");
    BlazeLayout.render('body');
  }
});

The imports/ui/body.js file loads a few other templates, like so:

import './moment.js';

And moment.js imports ./moment.html , like so:

import './moment.html';

But I get this error when visiting / :

Error: Cannot find module './moment.html'

The key thing to understand is that if I bypass FlowRouter altogether, by just putting import '../imports/ui/body.js into my client/main.js file, everything works fine.

Any ideas? Help is appreciated, thank you!

I just ran into this same problem, but I was thinking because routes.js was in lib it would get loaded first, moving it into clients means it get loaded with the other files so it can now be found. Not sure if this is correct but as you know, it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM