微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

错误:模板解析错误:'super-tab-button' 不是 ionic 3

如何解决错误:模板解析错误:'super-tab-button' 不是 ionic 3

我尝试在 angular ionic 3 中使用 super tab,但出现错误,我已经声明了 supertab,但它不起作用

ERROR Error: Uncaught (in promise): Error: Template parse errors:
'super-tab-button' is not a kNown element:
1. If 'super-tab-button' is an Angular component,then verify that it is part of this module.
2. If 'super-tab-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<super-tabs-toolbar slot="top" no-border>
 [ERROR ->]<super-tab-button (click)="switchTab('keyFields')">
      <ion-label>Key Fields</ion-label>
    </sup"): ng:///MyContactsDetailPageModule/MyContactsDetailPage.html@34:4


import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { SuperTabsModule } from 'ionic2-super-tabs';
import { MyContactsDetailPage } from './my-contacts-detail';

@NgModule({
  declarations: [
    MyContactsDetailPage,],imports: [
    IonicPageModule.forChild(MyContactsDetailPage),SuperTabsModule
  ],})
export class MyContactsDetailPageModule {}

这就是我在我的 html 中调用的方式

  <super-tabs-toolbar slot="top" no-border>
    <super-tab-button (click)="switchTab('keyFields')">
      <ion-label>Key Fields</ion-label>
    </super-tab-button>
    <super-tab-button (click)="switchTab('details')">
      <ion-label>Details</ion-label>
    </super-tab-button>
  </super-tabs-toolbar>

这是我的联系方式。ts

import { SuperTabsModule } from 'ionic2-super-tabs/dist/super-tabs.module';

@IonicPage()
@Component({
  selector: 'page-my-contacts-detail',templateUrl: 'my-contacts-detail.html',})
export class MyContactsDetailPage {
  private pageActive: any ;
  @ViewChild(SuperTabsModule) superTabs: SuperTabsModule;
  
  constructor(public navCtrl: NavController,public navParams: NavParams) {
  }

  ionViewDidLoad() {
    this.pageActive = 'keyFields';
  }

  private switchTab(page) {
    this.pageActive = page;
  }
}

你们能帮我解决这个问题吗?谢谢

解决方法

请将您的代码与 this example

进行比较

您的实施不正确。

模块被导入到其他模块中。

在您的组件中,您应该导入实际的类/组件

您的 contact-details.ts 应该是这样的:

import { SuperTabs } from 'ionic2-super-tabs';

@IonicPage()
@Component({
  selector: 'page-my-contacts-detail',templateUrl: 'my-contacts-detail.html',})
export class MyContactsDetailPage {
  private pageActive: any ;
  @ViewChild(SuperTabs) superTabs: SuperTabs;
  
  constructor(public navCtrl: NavController,public navParams: NavParams) {
  }

  ionViewDidLoad() {
    this.pageActive = 'keyFields';
  }

  private switchTab(page) {
    this.pageActive = page;
  }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。