.mat-cell { display: flex; align-items: center; padding: 0 16px; }
例如:在 custom-cell.component.ts 文件中,添加以下代码:
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-custom-cell',
template:
})
export class CustomCellComponent {
@Input() value: any;
@Input() backgroundColor: string;
}
例如,在 custom-cell.component.html 中添加以下代码:
例如,在组件中添加以下代码:
export interface Data { value: string; color?: string; }
数据中的 color 字段设置为元素的背景颜色。
这样就可以解决 mat-cell 组件未完全填充单元格背景颜色并将内容向上移动的问题。