【问题标题】:Error message while trying to build --Ionic App尝试构建时出现错误消息--Ionic App
【发布时间】:2020-11-16 08:09:38
【问题描述】:

这是我第一次尝试使用幻灯片构建应用程序并在选项卡之前登录,我在尝试构建时从幻灯片组件和开始时收到以下错误消息 和 离子构建--prod。我想我需要添加一些模块,比如 CUSTOM_ELEMENTS_SCHEMA 有人可以告诉我如何以及在哪里

ERROR in src/app/components/slides/slides.component.html:1:1 - error NG8001: 'ion-content' is not a 
known element:
1. If 'ion-content' is an Angular component, then verify that it is part of this module.
2. If 'ion-content' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' 
of this component to suppress this message.

1 <ion-content>

src/app/components/slides/slides.component.ts:5:16
5   templateUrl: './slides.component.html',
                 ~~~~~~~~~~~~~~~~~~~~~~~~~

组件 SlidesComponent 的模板发生错误。 src/app/components/slides/slides.component.html:2:3 - 错误 NG8001: 'ion-slides' 未知 元素: 1. 如果 'ion-slides' 是一个 Angular 组件,那么验证它是这个模块的一部分。 2. 如果 'ion-slides' 是一个 Web 组件,则将 'CUSTOM_ELEMENTS_SCHEMA' 添加到 '@NgModule.schemas' 的 此组件以禁止显示此消息。

2   <ion-slides pager="true" [options]="slideOpts">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/app/components/slides/slides.component.ts:5:16
5   templateUrl: './slides.component.html',
                 ~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component SlidesComponent.
src/app/components/slides/slides.component.html:2:28 - error NG8002: Can't bind to 'options' since it 
isn't a known property of 'ion-slides'.
1. If 'ion-slides' is an Angular component and it has 'options' input, then verify that it is part of 
this module.
2. If 'ion-slides' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of 
this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

2   <ion-slides pager="true" [options]="slideOpts">
                         ~~~~~~~~~~~~~~~~~~~~~

src/app/components/slides/slides.component.ts:5:16
5   templateUrl: './slides.component.html',
                 ~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component SlidesComponent.
src/app/components/slides/slides.component.html:3:5 - error NG8001: 'ion-slide' is not a known 
element:
1. If 'ion-slide' is an Angular component, then verify that it is part of this module.
2. If 'ion-slide' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of 
this component to suppress this message.

3     <ion-slide>
  ~~~~~~~~~~~

src/app/components/slides/slides.component.ts:5:16
5   templateUrl: './slides.component.html',
                 ~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component SlidesComponent.
src/app/components/slides/slides.component.html:8:5 - error NG8001: 'ion-slide' is not a known 
element:
1. If 'ion-slide' is an Angular component, then verify that it is part of this module.
2. If 'ion-slide' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of 
this component to suppress this message.

8     <ion-slide>
  ~~~~~~~~~~~

src/app/components/slides/slides.component.ts:5:16
5   templateUrl: './slides.component.html',
                 ~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component SlidesComponent.
src/app/components/slides/slides.component.html:12:5 - error NG8001: [0m'ion-slide' is not a known 
   element:
1. If 'ion-slide' is an Angular component, then verify that it is part of this module.
2. If 'ion-slide' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of 
this component to suppress this message.

12     <ion-slide>
   ~~~~~~~~~~~

src/app/components/slides/slides.component.ts:5:16
5   templateUrl: './slides.component.html',
                 ~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component SlidesComponent.
src/app/components/start/start.component.html:1:1 - error NG8001: 'ion-button' is not a known 
element:
1. If 'ion-button' is an Angular component, then verify that it is part of this module.
2. If 'ion-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of 
this component to suppress this message.

1 <ion-button expand="full" color='secondary' (click)="navigateToLoginPage()">Start</ion-button>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/app/components/start/start.component.ts:6:16
6   templateUrl: './start.component.html',
                 ~~~~~~~~~~~~~~~~~~~~~~~~
  Error occurs in the template of component StartComponent.

 [ERROR] An error occurred while running subprocess ng.

    ng.cmd run app:build:production exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

【问题讨论】:

  • slides.component.ts:5:16 - 如果有任何错误,请参阅第 5 行
  • 检查您的依赖注入,确认您已将组件添加到声明中:主模块侧的数组

标签: angularjs angular ionic-framework ionic4 ionic5


【解决方案1】:

检查您的依赖注入,确认您已将组件添加到声明中:主模块中的数组

例如:

declarations: [ AppComponent, HelloComponent,ImageComponent,PonyComponent,RaceComponent ],

而不是ion-button 使用下面的代码 &lt;button ion-button color="primary"&gt;Primary&lt;/button&gt;

要解决离子滑动问题,请使用以下 2 种解决方案中的任何一种

  1. 您需要将CUSTOM_ELEMENTS_SCHEMA 添加到NgModule. 中的架构中

    import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
    
     ...
    
     @NgModule({
       imports: [],
       ...
       schemas: [CUSTOM_ELEMENTS_SCHEMA]
     })
    
     export class YourModule {}
    
  2. 将 IonicModule.forRoot() 添加到父模块

@NgModule({ 进口:[ ... IonicModule.forRoot(), ] })

【讨论】:

    猜你喜欢
    • 2018-06-28
    • 2018-08-12
    • 2021-04-14
    • 1970-01-01
    • 1970-01-01
    • 2021-03-05
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    相关资源
    最近更新 更多