img 标签上的src 链接图片不存在时 怎么处理

// .html

<img [src]="nzSrc" *ngIf="nzSrc && hasSrc" (error)="imgError()"/>  

// .ts
imgError(): void { // 没有图片时会触发

  }

猜你喜欢

转载自www.cnblogs.com/flxy-1028/p/10951375.html