angular - 找不到不同的支持对象 NgStyle backgroundImage
问题描述
我正在尝试使用 Angular 在 div 中显示图像
我有:
<div
ngStyle="{'backgroundImage': 'url({{getImage()}})'}"
>
<div class="text-wrapper">
text
</div>
</div>
我正在通过的图片的地址:
ngOnInit() {
this.fullImagePath = 'assets/hackaton_home.png';
}
getImage() {
return this.fullImagePath;
}
该图像位于文件夹 assets 中。
我得到的错误是:
有什么帮助吗?
解决方案
<div [ngStyle]="{ 'background-image': 'url(' + fullImagePath+ ')'}"></div>
推荐阅读
- java - 如何使用具有场景形式的持久锚?
- javascript - 单击移动菜单正在删除内容
- c# - 加密外部键值缓存存储中的键和值
- java - JSON解析错误后的Spring Boot人类可读错误消息
- python - ImportError:使用 certbot 时无法导入名称 UnrewindableBodyError
- file - 在grails中上传文件创建的文件的路径格式是什么
- python - 这段代码的作用和含义是什么?
- javascript - 当另一个选择时,模块化 HTML JS 按钮不关闭菜单
- authentication - 使用表单身份验证不打开匿名用户无需登录即可查看的页面
- ios - 密码屏幕作为登录确认,Swift