首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >[style.background]中的插值问题

问[style.background]中的插值问题
EN

Stack Overflow用户
提问于 2021-03-13 06:46:42
回答 1查看 29关注 0票数 0

问题-我试图在artist.images.url中对Json图像进行插值,但是得到了一个错误。

Error - NG5002:解析器错误:缺少预期:['url(‘+ {{artist.images.url}} + ') no-repeat center center']中的第32列

图像url有效,但在插入时不起作用

作品

代码语言:javascript
复制
<mat-card
    [style.background]="'url(' + 'https://i.scdn.co/image/a402db0dbd2b33ca7141ea0fd31e4b81e178c39a' + ') no-repeat center center'"
    [style.background-size]="'cover'" [style.height]="'450px'">
</mat-card>

不工作

代码语言:javascript
复制
<mat-card
    [style.background]="'url(' + {{artist.images[0].url}} + ') no-repeat center center'"
    [style.background-size]="'cover'" [style.height]="'450px'">
</mat-card>
EN

回答 1

Stack Overflow用户

发布于 2021-03-13 06:49:48

你已经在做绑定了。

代码语言:javascript
复制
<mat-card
  [style.background]="'url(' + artist.images[0].url + ') no-repeat center center'"
  [style.background-size]="'cover'" [style.height]="'450px'">
</mat-card>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66608218

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档