流星面包屑 [英] Meteor breadcrumb
本文介绍了流星面包屑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 Meteor 和铁路由器实现反应性面包屑?
How do I implement a reactive breadcrumb with Meteor and iron-router?
现在,我正在寻找由反应式会话变量触发的当前路径,然后在 DOM 和 jQuery .
Now I'm looking for the current path, triggered by a reactive session variable and then adding each link that corresponds to that route inside the DOM with jQuery.
推荐答案
您可以在辅助函数中调用Router.current().path
,它将返回当前路径.然后在/
上拆分路径,并将数组返回到面包屑模板.该功能是响应式的,因此更新将传播:
You can call Router.current().path
inside a helper function and it will return the current path. Then split the path on /
and return the array to your breadcrumbs template. The function is reactive, so updates will propagate:
Template.breadcrumbs.path = function() {
return Router.current().path.split( "/" );
}
这篇关于流星面包屑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文