angular - Angular Material - mat-grid-list : 根据瓦片内容设置 mat-grid-tile 高度
问题描述
尝试创建一个 mat-grid-list,其中包含具有不同长度的动态内容的图块。但是,当尝试使用 rowspan 属性动态设置高度时,无法正确生成内容
<mat-grid-list [cols]="columnNum" rowHeight="225px">
<mat-grid-tile *ngFor="let number of [0,1,2,3,4,0,1,2,3,4,0,1,2,3,4]"
[rowspan]="CardContainer.offsetHeight>225?CardContainer.offsetHeight/225:1">
<div #CardContainer>
<mat-card>
<mat-card-header>
<!-- <img mat-card-avatar src="https://material.angular.io/assets/img/examples/shiba2.jpg"
alt="Photo of a Shiba Inu"> -->
<mat-card-title>
Shiba Inu {{CardContainer.offsetHeight}}
</mat-card-title>
<span class="titlebar-spacer"></span>
<!-- <mat-card-actions> -->
<button mat-icon-button>
<mat-icon>open_in_new</mat-icon>
</button>
<!-- </mat-card-actions> -->
</mat-card-header>
<mat-card-content>
<p>
The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from
Japan.
A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was
originally
bred for hunting.
</p>
<p *ngIf="number==3">
agile dog that copes very well with mountainous terrain, the Shiba Inu was originally
bred for hunting.
</p>
<p *ngIf="number==3|| number==4">
agile dog that copes very well with mountainous terrain, the Shiba Inu was originally
bred for hunting.
</p>
</mat-card-content>
</mat-card>
</div>
</mat-grid-tile>
</mat-grid-list>
解决方案
推荐阅读
- python - 有没有比 Python 中的 bool(sum(array)) 更好的方法来检查布尔数组是否包含至少一个 True 值?
- wordpress - 我如何将 reactjs 文件排入 wordpress 主题文件以使其在本地服务器中可见
- c# - 如何从 ASP.Net 中重复页脚行中的 DataTable 多列总计中求和
- python - 如何修复 bs4 选择错误:'TypeError: __init__() 关键字必须是字符串'
- c# - 如何对私有方法进行单元测试?
- angular - 具有未定义结果长度的角材料表分页器
- python-3.x - 在 for 循环中返回多行
- spring-boot - 如何让 Spring Boot 的自动重启在 IntelliJ IDEA 社区中工作?(out/build 目录问题)
- sql - 没有为此带有 SQL Server 的 DbContext .NET Core 配置数据库提供程序
- html - Bootstrap 4 全屏图像