我想获取路径以便为事件选项卡设置事件类。如果我每次点击“刷新”,代码就可以工作。
这是我的代码:
JS
Template.header.helpers({
isCurrentPage: function(pageName){
var pathArr = window.location.pathname.split("/");
var firstLevelPath = pathArr[1];
return firstLevelPath == pageName
}
});
HTML
<li role="presentation" class="{{#if isCurrentPage 'browse'}}active{{/if}}"><a href="{{pathFor 'browse'}}">Browse</a></li>
完整存储库
最佳答案
Iron.Location.get().path
返回实际路径并且是 react 性的,所以我想你可以使用这个
关于javascript - Meteor:为什么我的模板助手没有反应性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27930161/