Ember绑定样式属性问题

时间:2017-03-27 18:18:13

标签: javascript ember.js binding

我觉得我正在遵循文档,但我必须做错事。会爱你的帮助。

在我的模板中,我有:

<div style="{{backgroundImage}}">

在我的组件js文件中,我有:

backgroundImage: Ember.computed('background-image', function() {
  var imageUrl = this.item.attributes.imageMain.url;
  return Ember.String.htmlSafe('background-image: url('+ imageUrl +')');
})

事情进展顺利,但我仍在控制台收到警告:

WARNING: Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see http://emberjs.com/deprecations/v1.x/#toc_binding-style-attributes.

会喜欢任何帮助/第二只眼睛。非常感谢!!

1 个答案:

答案 0 :(得分:1)

感谢@kumkanillam。模板中的引号是额外的。

现在这就是模板的样子:

<div style={{backgroundImage}}>

相关问题