我正在使用 Angular 7“拖放”的新功能,我遵循了官方文档上的所有步骤:https : //material.angular.io/cdk/drag-drop/overview
但我收到此错误:**
未捕获的错误:模板解析错误:'cdk-drop' 不是已知元素: 1. 如果 'cdk-drop' 是一个 Angular 组件,则验证它是否是该模块的一部分。2. 如果'cdk-drop' 是一个Web 组件,则将'CUSTOM_ELEMENTS_SCHEMA' 添加到该组件的'@NgModule.schemas' 以抑制此消息。
**
这是我的 app.component.html 代码:
<cdk-drop cdkDropList class="example-list" (cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let movie of movies" cdkDrag>{{movie}}
</div>
</cdk-drop>
Run Code Online (Sandbox Code Playgroud)
这是我的 app.component.ts 代码:
import { Component } from '@angular/core';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
movies = [
'Episode I - The Phantom Menace',
'Episode II - Attack of the …Run Code Online (Sandbox Code Playgroud)