【问题标题】:template parse error is not a known element (ionic)模板解析错误不是已知元素(离子)
【发布时间】:2017-09-21 02:33:53
【问题描述】:

感谢您从现在开始的帮助! 我遇到了这个问题,我正在做一个可消耗的列表,请按照我的 app.module.ts 中的代码:

        import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { ExpansivoComponent } from '../components/expansivo/expansivo';


@NgModule({
  declarations: [
    MyApp,
    ExpansivoComponent
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)

  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp

  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

这是我的html页面代码:

<ion-header>

  <ion-navbar>
    <ion-title>listacli</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>
  <ion-list>
    <ion-item *ngFor="let item of items">
      <ion-thumbnail item-start>
        <img src="assets/img/listacli.png">
      </ion-thumbnail>
      <h2>My Neighbor Totoro</h2>
      <p>Hayao Miyazaki • 1988</p>
      <expansivo></expansivo>
      <button ion-button clear item-end>View</button>
    </ion-item>
  </ion-list>
</ion-content>

i already tryied a lot of answers from stackoverflow, but anything could help :(

这是error

如果你们需要任何代码,请询问,谢谢!

【问题讨论】:

  • 只是要记住是在乞求组件,这个组件还不是一个可扩展的列表。但如果我在离子服务上写 hello word,它应该可以工作!

标签: list ionic-framework components expandable


【解决方案1】:

您必须将您的 ExpansivoComponent 添加到 entryComponents

    @NgModule({
  declarations: [
    MyApp,
    ExpansivoComponent
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)

  ],
  bootstrap: [IonicApp],
  entryComponents: [
        MyApp,
        ExpansivoComponent 
      ],

【讨论】:

  • Então,não funcionou,o erro se manteve。 Eu ja tinha tentado isso。 :( 所以它没有用。我已经试过了。
  • 你能显示来自 ExpansivoComponent 的元数据 (@component())
  • 作为答案
猜你喜欢
  • 1970-01-01
  • 2020-04-19
  • 2020-02-08
  • 2018-10-15
  • 2021-11-26
  • 1970-01-01
  • 2018-02-07
  • 2020-04-08
  • 1970-01-01
相关资源
最近更新 更多