Javascript Ember.js带有外部/出站链接的每个循环
您好,提前谢谢您的帮助。我正在使用ember.js创建一个基本站点。我有一个each循环,我希望它在链接到外部站点时显示一个变量(例如,google.com,我将其存储为不同的变量) 出于某种原因,当我在每个循环中执行内部操作时,我得到了一个错误,“此链接处于非活动加载状态,因为它的至少一个参数当前具有空/未定义的值,或者提供的路由名称无效。”单击时,我似乎无法弄清楚如何将其转到外部站点。下面是我的each循环和示例jsonJavascript Ember.js带有外部/出站链接的每个循环,javascript,jquery,ember.js,Javascript,Jquery,Ember.js,您好,提前谢谢您的帮助。我正在使用ember.js创建一个基本站点。我有一个each循环,我希望它在链接到外部站点时显示一个变量(例如,google.com,我将其存储为不同的变量) 出于某种原因,当我在每个循环中执行内部操作时,我得到了一个错误,“此链接处于非活动加载状态,因为它的至少一个参数当前具有空/未定义的值,或者提供的路由名称无效。”单击时,我似乎无法弄清楚如何将其转到外部站点。下面是我的each循环和示例json {{#each}} {{#link-to 'theme'
{{#each}}
{{#link-to 'theme' theme tagName="tr"}}
<td class="noWrap">{{#link-to 'theme' title}}{{title}}{{/link-to}}</td>
<td>{{#link-to 'theme' this}}<img {{bind-attr src="image"}} \>{{/link-to}}</td>
<td class="tdCenter"><a {{bind-attr href="link"}}>{{price}}</a></td>
<td>{{description}}</td>
<td class="tdCenter">{{columns}}</td>
{{/link-to}}
{{/each}}
{
id: 1,
title: 'Title',
price: '$10',
description: 'random description',
columns: 1,
link:'https://google.com',
image: 'images/image.jpg'
}
如果你有任何想法,请告诉我。再次感谢
David B如果将{{{#指向'theme'主题标记名=“tr”}}
的链接替换为
,则表行将在没有链接的情况下呈现(除非这是不可接受的,不幸的是,指向
助手的链接当时的用途我不清楚)
所以结果会是
hbs
<script type="text/x-handlebars" data-template-name="theme">
<table>
{{#each}}
<tr>
<td class="noWrap">{{#link-to 'theme' title}}{{title}}{{/link-to}}</td>
<td>{{#link-to 'theme' this}}<img {{bind-attr src="image"}} \>{{/link-to}}</td>
<td class="tdCenter"><a {{bind-attr href="link"}}>{{price}}</a></td>
<td>{{description}}</td>
<td class="tdCenter">{{columns}}</td>
</tr>
{{/each}}
</table>
</script>
{{{#各}
{{{#链接到“主题”标题}{{title}{{/link to}}
{{{{链接到'主题'这个}{{/链接到}}
{{description}}
{{columns}}
{{/每个}}
顺便说一下,显示的错误是由于
{{#link to'theme'theme tagName=“tr”}}
中的参数主题
造成的,如果删除该参数,错误将消失,但呈现的html将无法正常工作(至少我在我提供的快速示例中注意到),因为{#link to}
helper在这一点上。第一个链接中的主题是什么?应该是这个吗?谢谢!!我想我需要这个链接,这样它就知道该循环什么了,但显然我不需要。谢谢你的帮助!!
<script type="text/x-handlebars" data-template-name="theme">
<table>
{{#each}}
<tr>
<td class="noWrap">{{#link-to 'theme' title}}{{title}}{{/link-to}}</td>
<td>{{#link-to 'theme' this}}<img {{bind-attr src="image"}} \>{{/link-to}}</td>
<td class="tdCenter"><a {{bind-attr href="link"}}>{{price}}</a></td>
<td>{{description}}</td>
<td class="tdCenter">{{columns}}</td>
</tr>
{{/each}}
</table>
</script>