gpt4 book ai didi

ionic-framework - ionic : module has no exported member

转载 作者:行者123 更新时间:2023-12-03 23:22:40 32 4
gpt4 key购买 nike

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

ionic start ionic-welcome tabs
ionic serve

我使用以下命令创建一个新页面
ionic g page welcome

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

[OK] Generated a page named 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 时,我收到了“欢迎页面”的这个错误。

Module '"C:/xampp/htdocs/ionic/ionic-welcome/src/pages/welcome/welcome"' has no exported member 'Welcome'.



包.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

最佳答案

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

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

祝你好运

关于ionic-framework - ionic : module has no exported member,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45733682/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com