首页 > 解决方案 > 如何在 Angular 11 和 '@aws-amplify/ui-angular' 中删除“amplify-authenticator 不是已知元素”

问题描述

在网上四处寻找答案,没有看到任何东西。可能是因为这并不难诊断和修复,但我想我会发布这个,以便它可以为其他人节省几分钟的时间。

我在使用 AWS Amplify 的 Authenticator 组件时遇到了问题。按照此处的基本设置-> https://docs.amplify.aws/ui/auth/authenticator/q/framework/angular

将 Amplify Angular UI 组件添加到我的 app.component.html 后,我的 IDE(VS 代码)抱怨它无法识别 UI 组件。文档中没有关于如何解决这个问题的任何内容。

标签: angularaws-amplify

解决方案


IDE 抱怨的原因是这些是 Web 组件,因此您需要将 CUSTOM_ELEMENTS_SCHEMA 添加到您的模块中

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    AmplifyUIAngularModule,
    AppRoutingModule,
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA], // <---this right here
  providers: [],
  bootstrap: [AppComponent],
})

推荐阅读