【发布时间】:2014-12-11 23:52:19
【问题描述】:
【问题讨论】:
标签: meteor iron-router
【问题讨论】:
标签: meteor iron-router
您可以在辅助函数中调用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() {} 添加方法的方式已弃用。
【讨论】: