How do I create multi-page applications with Meteor?

前端 未结 5 2046
醉话见心
醉话见心 2021-01-29 21:23

I am new to Javascript and just started fiddling around with Meteor out of curiosity. What really surprises me, is that it seems that all HTML content gets combined into a singl

5条回答
  •  天涯浪人
    2021-01-29 21:57

    Meteor-Router makes this really easy. I've been using it in some apps I've been building with Telescope as a good reference. Have a look at Telescope's router.js

    To use it…

    mrt add router

    In client/router.js:

    Meteor.Router.add({
      '/news': 'news', // renders template 'news'
    
      '/about': function() {
        if (Session.get('aboutUs')) {
          return 'aboutUs'; //renders template 'aboutUs'
        } else {
          return 'aboutThem'; //renders template 'aboutThem'
        }
      },
    
      '*': 'not_found'
    });
    

    In your template…

    {{renderPage}}
    

提交回复
热议问题