更新时间:2023-11-22 17:09:22
错误本身表明指令不存在于 组件,因为它已被弃用.试试下面显示的代码,
Error itself says that directives doesn't exist in Component as it has been deprecated. try this code shown below,
import { MyComponentComponent } from './my-component/my-component.component'
import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
@NgModule({
...
...
declarations:[AppComponent,MyComponentComponent], //<---need to declare
schemas: [CUSTOM_ELEMENTS_SCHEMA] //<---added this line
})
并从 AppComponent 中删除 directives:[MyComponentComponent].