问题描述
我尝试在 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;
}
}