Angular“必须导入或本地”错误

时间:2017-11-05 16:50:09

标签: angular typescript ionic-framework ionic3

我正在尝试创建一个离子应用程序,当我在离子创建器中将页面链接在一起时,我在.ts文件中收到错误,如下所示:

 typescript: src/pages/home/home.ts, line: 4 
            Individual declarations in merged declaration 'HomePage' must be all exported or all local. 

       L3:  import { NotificationsPage } from '../notifications/notifications';
       L4:  import { HomePage } from '../home/home';
       L5:  import { MyPatientsPage } from '../my-patients/my-patients';

以下是我的.ts文件中的代码:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NotificationsPage } from '../notifications/notifications';
import { HomePage } from '../home/home';
import { MyPatientsPage } from '../my-patients/my-patients';
import { AllPatientsPage } from '../all-patients/all-patients';
import { LoginPage } from '../login/login';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {
  }
  goToNotifications(params){
    if (!params) params = {};
    this.navCtrl.push(NotificationsPage);
  }goToHome(params){
    if (!params) params = {};
    this.navCtrl.push(HomePage);
  }goToMyPatients(params){
    if (!params) params = {};
    this.navCtrl.push(MyPatientsPage);
  }goToAllPatients(params){
    if (!params) params = {};
    this.navCtrl.push(AllPatientsPage);
  }goToLogin(params){
    if (!params) params = {};
    this.navCtrl.push(LoginPage);
  }
}

1 个答案:

答案 0 :(得分:5)

您不能import HomePage文件中的home.ts Line 4

需要从home.ts文件

中删除以下导入内容
import { HomePage } from '../home/home';