【问题标题】:'ion-progress-bar' is an Angular component, then verify that it is part of this module'ion-progress-bar' 是一个 Angular 组件,然后验证它是这个模块的一部分
【发布时间】:2020-09-05 21:48:57
【问题描述】:

我正在尝试在我的 ionic 应用程序中使用“ion-progress-bar”。但它抛出了以下错误。

我尝试寻找解决方案,但不知何故无法解决。请提出错误在哪里。

我的 home.html 如下所示:

<ion-content>
<ion-progress-bar></ion-progress-bar>  
</ion-content>

在我的 app.module.ts 中,我有以下内容:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';

错误如下:

Error: Template parse errors:
'ion-progress-bar' is not a known element:
1. If 'ion-progress-bar' is an Angular component, then verify that it is part of this module.
2. If 'ion-progress-bar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<!-- <ion-progress-bar value="0.5"></ion-progress-bar> -->

[ERROR ->]<ion-progress-bar></ion-progress-bar>  

【问题讨论】:

  • 验证 IonProgressBar 是否在 IonicModule 中导出,并确保 IonicModule 在您的导入数组中。另外,你的 home 组件在你的 app.module 中吗?

标签: html angular ionic-framework ionic4


【解决方案1】:

检查天气你在 app.module.ts 中注册了这个组件 IonProgressBar 喜欢

declarations: [
    MyApp ,
    IonProgressBar 
  ]

也在 IonProgressBar .ts 文件中检查

@Component({
  selector: 'ion-progress-bar',
  ----------------------------
  ----------------------------
})

【讨论】:

  • 它抛出错误:找不到名称'AppComponent'.ts(2304) 和找不到名称'IonProgressBar'.ts(2304)
猜你喜欢
  • 2017-10-11
  • 2021-01-23
  • 2021-04-20
  • 2023-03-03
  • 2018-07-07
  • 2018-07-08
  • 2021-11-11
  • 1970-01-01
  • 2021-12-02
相关资源
最近更新 更多