Assignment to read-only properties is not allowed in strict mode in [background: url({{XXX}}) no-repeat center center

风流意气都作罢 提交于 2019-12-10 22:23:50

问题


I am getting this error in Edge but in chrome everything is fine Unable to understand what is wrong here...

<div class="container-fluid project_img" style="background: url({{_project.images.web}}) no-repeat center center;">
      </div> 

Error in Microsoft Edge:

Assignment to read-only properties is not allowed in strict mode in [background: url({{_project.images.web}}) no-repeat center center; in ProjectDetailComponent

回答1:


Use instead

<div class="container-fluid project_img" [style.background]="'url(' + _project.images.web + ') no-repeat center center;'">
  </div> 



回答2:


This is how it worked for me

<div class="container-fluid project_img" attr.style.background="url({{_project.images.web}}) no-repeat center center;">


来源:https://stackoverflow.com/questions/36198547/assignment-to-read-only-properties-is-not-allowed-in-strict-mode-in-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!