ionic:模块没有导出成员

时间:2017-08-17 11:17:09

标签: ionic-framework

我是离子框架的新手,刚刚开始。我在Windows上工作。我用这个命令创建了我的应用程序:

ionic start ionic-welcome tabs
ionic serve

我使用以下命令

创建一个新页面
ionic g page welcome

我在控制台中收到此回复:

  

[确定]生成一个名为welcome!的页面。

更新欢迎页面的app.module.ts:

import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';

import { Welcome } from '../pages/welcome/welcome';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

@NgModule({
  declarations: [
    MyApp,
    Welcome,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    Welcome,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

但是当我浏览到localhost:8100时,我收到了这个错误#34;欢迎页面"。

  

模块   '" C:/ XAMPP / htdocs中/离子/离子-欢迎/ SRC /页/欢迎/欢迎"'具有   没有出口会员'欢迎'。

的package.json:

{
  "name": "ionic-welcome",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.6.0",
    "ionicons": "3.0.0",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.1.3",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project"
}

有人说要删除' ^'来自package.json的角色,但没有一个。我没有选择,不知道接下来该做什么,请帮忙。 enter image description here

1 个答案:

答案 0 :(得分:9)

如果您查看Welcome.ts,您可能会找到类似这样的内容

export class WelcomePage {

constructor(public navCtrl: NavController, public navParams: NavParams)
{
}

ionViewDidLoad() {
console.log('ionViewDidLoad WelcomePage');
}
你的app.modules.ts中的

执行以下操作

import { WelcomePage } from '../pages/welcome/welcome'

然后将WelcomePage添加到声明和entryComponents。

我刚遇到这个问题并设法以这种方式解决它。

祝你好运