2

我尝试在 angular ionic 3 中使用超级选项卡,但出现错误,我已经声明了超级选项卡,但它不起作用

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;
  }
}

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

4

1 回答 1

0

请将您的代码与此示例进行比较

您的实现不正确。

模块在其他模块中导入。

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

您的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;
  }
}
于 2021-01-29T06:36:48.333 回答