小编Gae*_*tan的帖子

是否可以禁用在 cdkDrag 的子元素上拖动?

我正在使用来自 Angular Material 的 Angular CDK 拖放(请参阅此处的文档)。我想知道是否可以禁用cdkDrag. 问题是无法input使用鼠标选择可拖动元素中写入的内容。

所以,我想要做的是禁止拖动input具有cdkDrag指令的元素下的所有元素

我试过使用:

  • cdkDragHandle:这会将拖动放在特定元素上,而不是我想在这里做的
  • cdkDragDisabled:这将禁止拖动整个元素,而不是我想在这里做的

这是我的代码的样子:

<div cdkDropList (cdkDropListDropped)="drop($event)">
    <div *ngFor="let element of array" cdkDrag>
        <div>
            <mat-form-field>
                <mat-label>Input 1</mat-label>
                <input matInput type="text">
            </mat-form-field>
            <mat-form-field>
                <mat-label>Input 2</mat-label>
                <input matInput type="number">
            </mat-form-field>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

提前感谢您的帮助和时间。

angular-material angular angular-cdk

5
推荐指数
1
解决办法
941
查看次数

如何使用 Mapstruct 和 Kotlin 在另一个映射器中使用一个映射器?

我想在Kotlin中使用Mapstruct将实体映射到具有嵌套 DTO 的 DTO

我的第一个 DTO 定义如下:

data class FirstDto (
    val something: String
)
Run Code Online (Sandbox Code Playgroud)

该 DTO 使用 Mapstruct 映射到实体中,反之亦然。这是映射器:

@Mapper(componentModel = "spring")
interface FirstMapper {

    fun entityToDto(entity: FirstEntity): FirstDto

    fun dtoToEntity(dto: FirstDto): FirstEntity
}
Run Code Online (Sandbox Code Playgroud)

第二个 DTO 嵌套第一个 DTO:

data class SecondDto (
    val somethingElse: String,
    val firstDto: FirstDto
)
Run Code Online (Sandbox Code Playgroud)

对于第一个DTO,我使用Mapstruct定义了一个Mapper。但是,我希望这个映射器使用FirstMapper来映射嵌套的 DTO。所以我应该使用Mapperuses的属性。

在 Java 中,这看起来像这样:@Mapper(componentModel = "spring", uses = FirstMapper.class)

应该如何使用Kotlin来实现?

java spring kotlin mapstruct

2
推荐指数
1
解决办法
1万
查看次数