【发布时间】:2026-02-05 08:45:01
【问题描述】:
如何在流星模板中传递当前路径
{{> sometemplate somearg="{{currentpath}}" }}
当前路径基本上是window.location.pathname返回的路径
【问题讨论】:
标签: meteor
如何在流星模板中传递当前路径
{{> sometemplate somearg="{{currentpath}}" }}
当前路径基本上是window.location.pathname返回的路径
【问题讨论】:
标签: meteor
您可以为此使用一个简单的助手:
Template.parentTemplate.helpers({
currentPath: function() {
return window.location.pathname;
}
});
然后在你的模板中调用它:
<template name="parentTemplate>
{{!-- ... --}}
{{> sometemplate somearg=currentPath }}
</template>
【讨论】: