gpt4 book ai didi

javascript - 与 Ember.js 的部分静态属性绑定(bind)?

转载 作者:行者123 更新时间:2023-11-28 08:33:56 25 4
gpt4 key购买 nike

是否可以将部分静态属性与 Ember.js 绑定(bind)?

它应该类似于以下示例:

<img class="" {{bind-attr src='App.Data.staticResourceUrl/iceAndFire.jpg'}}>

谢谢您,如果您需要更多信息,请告诉我。

编辑:

当然你可以将它实现为这样的 View :

App.StaticImage = Ember.TextField.extend(Ember.ViewTargetActionSupport, {
tagName: 'img',
attributeBindings: ['src', 'path'],

src: function() {
return App.Data.get('staticResourceUrl')+'/'+this.get('path');
}.property('path')
});

并像这样使用它:

{{view "App.StaticImage" path="/Images/deathlyHallows.jpg"}}

如果您知道更好的解决方案,我会很高兴知道。

最佳答案

如果该属性不会在您身上更新,您可以将其未绑定(bind)地注入(inject)。

<img class="" src='{{unbound App.Data.staticResourceUrl}}/iceAndFire.jpg'>

http://emberjs.jsbin.com/AwACotA/1/edit

关于javascript - 与 Ember.js 的部分静态属性绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21479659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com