刚开始玩meteor,我正在尝试使用iron-router
进行路由。这是我的数据结构:
team
_id
name
tags:[{name,counter}]
这是我尝试在模板中使用的链接
{{#each team.tags}}
<a href="{{ pathFor 'team' _id=../team._id query='search='+this.name }}">{{this.name}} <span class="count-list">{{this.counter}}</span></a>
{{/each}}
我的路由器有:
route('/team/:_id') // And I get the search through the GET property... this.params.query
但它不喜欢 query='search='+this.name
,我该如何使其工作?
最佳答案
因为它是一个 GET
方法,所以这应该有效:
{{#each team.tags}}
<a href="{{ pathFor 'team' _id=../team._id}}/?search={{this.name}}">{{this.name}} <span class="count-list">{{this.counter}}</span></a>
{{/each}}
否则,您必须在预先的帮助程序(或 registerHelper 函数)中构建 URL,因为空格键不允许复合操作。
关于javascript - 在 pathFor iron-router 中的查询中使用当前每个数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29155555/