Ember - 如何在没有 html 的情况下呈现视图的属性

Ember - how to render a view's property without html

本文关键字:情况下 属性 视图 html Ember      更新时间:2023-09-26

我有一个带有currentUrl属性的Ember视图;此属性在调用视图时获取值,如下所示:

{{view App.MyView currentUrl="www.website.com"}}

在视图的模板中,我有这样的东西:

<a href="{{view.currentUrl}}">

但这不起作用,因为车把表达式的输出是:

<script%20id='metamorph-4-start'%20type='text/x-placeholder'></script>www.website.com<script%20id='metamorph-4-end'%20type='text/x-placeholder'></script>

不仅像我想要的那样 www.website.com; 你知道如何在没有HTML的情况下获得输出吗?

也许你可以在这里使用 {{unbound}} 助手。

<a href="{{unbound view.currentUrl}}">

或 {{bind-attr}} 帮助程序

<a {{bind-attr href="view.currentUrl"}}>

取决于是否希望属性实时更新(绑定)或不实时更新(未绑定)