我正在为我的 meteor 项目使用铁路由器,一切顺利,但我遇到了一些奇怪的行为。
我为看起来像这样的项目列表设置了一个循环。
{{#each list_items}}
<div>{{user.username}}
<a href="{{link}}">Click here!</a>
</div>
{{/each}}
我的用户的 JSON 对象如下所示:
{
user: {
username: jdoe
},
images: {
low-res-url: http://example.com
},
link: http://example.com/profile
}
现在 {{user.username}} 按预期显示,但是当我尝试将 {{link}} 放在 href 中时,我收到了来自 Iron-router 的错误消息
"You called Router.path for a route named undefined but that that route doesn't seem to exist. Are you sure you created it?"
任何帮助或建议将不胜感激。
最佳答案
在引擎盖下 Iron-Router 注册handelbars helper:
Handlebars.registerHelper('link', function (options) {
...
});
只需更改字段
link
到不同的名称,如 my_link
.
关于meteor - Handlebars + meteor +铁路由器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19877813/