您可以为每个目的使用句柄。
例子
用于拖放;而不是
<mat-header-cell
*matHeaderCellDef
(mousedown)="onResizeColumn($event, i)"
cdkDropList
cdkDropListLockAxis="x"
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="dropListDropped($event, i)"
cdkDrag
[cdkDragData]="{ name: column.field, columIndex: i }"
(cdkDragStarted)="dragStarted($event, i)"
>
{{ column.field }}
</mat-header-cell>
你可以使用;
<mat-header-cell
*matHeaderCellDef
(mousedown)="onResizeColumn($event, i)"
cdkDropList
cdkDropListLockAxis="x"
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="dropListDropped($event, i)"
cdkDrag
[cdkDragData]="{ name: column.field, columIndex: i }"
(cdkDragStarted)="dragStarted($event, i)"
>
{{ column.field }}
<mat-icon cdkDragHandle>drag_handle</mat-icon>
</mat-header-cell>
类似于调整大小,而不是;
<mat-header-cell
*matHeaderCellDef
(mousedown)="onResizeColumn($event, i)"
cdkDropList
cdkDropListLockAxis="x"
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="dropListDropped($event, i)"
cdkDrag
[cdkDragData]="{ name: column.field, columIndex: i }"
(cdkDragStarted)="dragStarted($event, i)"
>
{{ column.field }}
<mat-icon cdkDragHandle>drag_handle</mat-icon>
</mat-header-cell>
你可以使用;
<mat-header-cell
*matHeaderCellDef
cdkDropList
cdkDropListLockAxis="x"
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="dropListDropped($event, i)"
cdkDrag
[cdkDragData]="{ name: column.field, columIndex: i }"
(cdkDragStarted)="dragStarted($event, i)"
>
{{ column.field }}
<mat-icon cdkDragHandle>drag_handle</mat-icon>
<mat-icon (mousedown)="onResizeColumn($event, i)">switch_left</mat-icon>
</mat-header-cell>
也许两者都有句柄会更好。
我使用了 mat-icon,你应该将 MatIconModule 从 @angular/material 包导入到你的模块中。
Stackblitz Edited Version