【问题标题】:ionic: module has no exported member离子:模块没有导出成员
【发布时间】:2018-01-25 18:49:46
【问题描述】:

我是 ionic 框架的新手,现在才开始。我在窗户上工作。我用这个命令创建了我的应用程序:

ionic start ionic-welcome tabs
ionic serve

我使用以下命令创建一个新页面

ionic g page welcome

我在控制台中收到此响应:

[OK] 生成了一个名为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 时,“欢迎页面”出现此错误。

模块 '"C:/xampp/htdocs/ionic/ionic-welcome/src/pages/welcome/welcome"' 有 没有导出成员“欢迎”。

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 中删除 '^' 字符,但没有。我没有选择,不知道下一步该怎么做,请帮助。

【问题讨论】:

    标签: ionic-framework


    【解决方案1】:

    如果您检查 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。

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

    祝你好运

    【讨论】:

      猜你喜欢
      • 2017-08-26
      • 1970-01-01
      • 2017-05-20
      • 2017-05-07
      • 2017-08-18
      • 1970-01-01
      • 2017-09-09
      • 2022-01-12
      相关资源
      最近更新 更多