這是我的 css 文件,我正在嘗試這樣做:
.login-wrapper {
background-image: url({{imagePath}});
}
我的組件:
export class LoginComponent implements OnInit {
imagePath: any = 'assets/discord-logo.png';
constructor() {}
ngOnInit() {}
}
它不起作用。
如何將“imagePath”從我的組件注入 css 文件?
謝謝你的幫助
您可以像這樣在 html 文件中應用內聯 css:
<div class="div" [style.backgroundImage]="'url('+imageUrl+')'">
</div>
演示鏈接:https : //stackblitz.com/edit/angular-ivy-1rf1tl?file= src/app/ app.component.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句