简体   繁体   中英

Meteor.js: iron:router including name

In tutorials I found two ways of using iron:router:

First one:

Router.route("/", function(){
    this.render("navbarMain", {
        to: "navigation"
    });
    this.render("firstPage",{
        to: "main"
    });

Second one:

Router.route("/", {
    name: "home",
    template: "home"
});

I would like to add name attribute to the first code; I tried adding it in differenet places, but none seems to work. Where should I put it or there is no way to combine those two? In that case, how can I refer to the root page (in pathFor)?

This should work.

Router.route("/", function(){
  this.render("navbarMain", {
    to: "navigation"
  });
  this.render("firstPage",{
    to: "main"
  });
}, {
  name: 'home'
});

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