1

当它出现在 Angular 7 上时,我切换到延迟加载功能,在此之前,cdk 拖放曾经可以工作,现在它坏了。

我在代码中使用了一些共享模块来集中模块,例如,每当我需要模块 A,B,C 时,我只导入模块 D ,它本身会导入这些提到的模块。

我尝试在这些共享模块之一中导入位于@angular/cdk/drag-drop 中的 DragDropModule,但它没有用。

我还仔细检查了这些模块是否在任何地方都被导入。

请注意,我确保共享模块也已导出。

共享模块

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import {DragDropModule} from '@angular/cdk/drag-drop';


@NgModule({
  declarations: [],
  imports: [DragDropModule, CommonModule],
  exports : [DragDropModule]
})
export class DragDropSharedModule {}

在其他共享模块内部

import {DragDropSharedModule} from './core-shared/drag-drop.module'

@NgModule({
  declarations: [
    NavbarComponent,
    AppComponent,
    // TimeAgoPipe,
    RmSetTextComponent,
    // ToggleComponent,
    KeysPipe,
    TimeAgoPipe
    // LoadingComponent
    ////////////// AclControlComponent,
    ///////////// AclGroupListComponent,
    ////////////////////// AclPermissionComponent,
    ///////////// SelectedItemsPipe

  ],
  imports: [
    // BrowserModule,
    ReactiveFormsModule,
    FormsModule,
    Ng2FileInputModule.forRoot(),
    Ng2ImgFallbackModule,
    CommonModule,
    HttpClientModule,
    // DragDropModule,
    ScrollingModule,
    NotFountPageModule,
    RmTableModule,
    ToggleModule,
    DragDropSharedModule
  ]
4

2 回答 2

0

这是我如何让它工作

<ng-container *ngFor="let item of [1,2,3,4,5]">
<cargo cdkDrag (cdkDragEnded)="dragEnded($event)">hello</cargo>
</ng-container>
于 2020-02-08T19:27:44.190 回答
0

解决了

我没有在其中一个共享模块中导入拖放模块

于 2020-02-10T15:55:24.500 回答