假设我有以下代码:
<img [src]="JwtService.characterImage(enemy)" class="{{enemy.status}}" (click)="sidenav.toggle();" style="cursor:pointer">
我如何从我的组件.ts文件中更改此img src asttribute?
在组件中添加imgSrc
class Component { constructor(jwtService: JwtService) { this.imgSrc = JwtService.characterImage(enemy); } } <img [src]="imgSrc" class="{{enemy.status}}" (click)="sidenav.toggle();" style="cursor:pointer">