css - Angular - 我如何将 Api 中的图像设置为背景图像
问题描述
我尝试将从我的 api 获得的图像设置为来自我的标题的背景图像。但它不会按预期工作......
这是我的代码:
<div class="container">
<div class="header" [ngStyle]="{background: 'url('userProfile.headerImagePath')'}">
...
css
.header {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 500px;
min-width: 100%;
background-color: yellowgreen;
}
解决方案
请使用以下代码。
<div class="header" [ngStyle]="{background: 'url('+userProfile.headerImagePath+')'}">
...
推荐阅读
- wordpress - WooCommerce:站点范围的 cookie 过滤器
- asp.net-core - NLog 未将日志发送到 AWS CloudWatch
- javascript - 使用javascript在虚拟键盘上按下键时自动提示文本区域
- javascript - 当在 url 中推送查询参数同时保持在同一路径上时,Vue.js 中的“NavigationDuplicated”异常是否有任何解决方法
- javascript - 中键点击标签栏打开新标签
- c# - C# .NET 验证功能不会影响两个输入字段
- r - 在 r 中的 sf MULTIPOLYGON 内生成样本
- postgresql - PostgreSQL 何时在后台创建临时表?
- android - 单击 fcm 通知而不是打开启动器活动时打开浏览器
- python - 使用不同的参数同时运行相同的函数