我正在尝试在项目列表中动态生成route-href
。我基本上有这个:
this.items = [
{
name: 'Foo',
route: 'item',
routeParams: {
id: 1
}
},
{
name: 'Bar',
route: 'item',
routeParams: {
id: 2
}
}
];
在我看来:
<ul>
<li repeat.for="item of items">
<a route-href="route: ${item.route}; params.bind: ${item.routeParams}">
${item.name}
</a>
</li>
</ul>
但Aurelia告诉我:
aurelia-logging-console.js:54 ERROR [route-href] Error: A route with name 'undefined' could not be found. Check that `name: 'undefined'` was specified in the route's config
如果我打印${item.route}
和${item.routeParams}
,则确实包含正确的值:
<ul>
<li repeat.for="item of items">
<a route-href="route: ${item.route}; params.bind: ${item.routeParams}">
${item.name} ${item.route} ${item.routeParams}
</a>
</li>
</ul>
为什么呢? :/
答案 0 :(得分:7)
正确的语法是:
<a route-href="route.bind: item.route; params.bind: item.routeParams">...</a>
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/cheat-sheet/7
的更多信息