Meteor 流星面包屑

Meteor 流星面包屑,meteor,iron-router,Meteor,Iron Router,我如何使用和熨斗路由器实现反应式面包屑 现在我正在寻找当前路径,由一个被动会话变量触发,然后在with中添加与该路径对应的每个链接。您可以在helper函数中调用Router.current().path,它将返回当前路径。然后在/上拆分路径,并将数组返回到面包屑模板。该函数是被动的,因此更新将传播: Template.breadcrumbs.path = function() { return Router.current().path.split( "/" ); } 使用Meteor

我如何使用和熨斗路由器实现反应式面包屑


现在我正在寻找当前路径,由一个被动会话变量触发,然后在with中添加与该路径对应的每个链接。

您可以在helper函数中调用
Router.current().path
,它将返回当前路径。然后在
/
上拆分路径,并将数组返回到面包屑模板。该函数是被动的,因此更新将传播:

Template.breadcrumbs.path = function() {
  return Router.current().path.split( "/" );
}

使用Meteor 1.0和Iron.Router,它将是:

Template.breadcrumbs.helpers({
  path: function() {
    return Router.current().route.path(this).split( "/" );
  }
});

请注意,将方法添加到模板引擎
template.breadcrumbs.path=function()!我为meteor创建了一个更高级的插件,它与iron路由器一起生成面包屑: