我的离子版本:
ionic (Ionic CLI) : 4.2.1
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0
错误:
Error: C:\...\src\pages\buyer-form\buy-sell\buy-sell.ts has
a @IonicPage decorator, but it does not have a corresponding "NgModule" at
C:\...\src\pages\buyer-form\buy-sell\buy-sell.module.ts
页面:
import { Component } from '@angular/core';
import {NavController, NavParams, ToastController, IonicPage} from 'ionic-angular';
import { Events } from 'ionic-angular';
@IonicPage({
name: 'BuySellPage',
priority: 'high'
})
@Component({
selector: 'page-buy-sell',
templateUrl: 'buy-sell.html',
})
export class BuySellPage {
constructor(public navCtrl: NavController, public navParams: NavParams,
public events: Events) {
}
}
Page.module:
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ComponentsModule } from '../../../components/components.module';
import { BuySellPage } from './buy-sell';
@NgModule({
declarations: [
BuySellPage
],
imports: [
IonicPageModule.forChild(BuySellPage),
ComponentsModule,
],
exports: [
BuySellPage
],
entryComponents: [
BuySellPage
]
})
export class BuySellModule {}
应用模块:
...
imports: [
...
IonicModule.forRoot(MyApp, {
mode: 'ios',
preloadModules: true
}),
...
BuySellModule ]
...
我认为我做对了所有事情,在module
中声明了app.module
,然后在page.module
中声明了page
,并在页面中写了@IonicPage
装饰器。该page
有自己的模块,该模块使用以下内容声明页面:IonicPageModule.forChild(BuySellPage)
。
那是什么问题?
不,这不是来自-> This question的重复问题,因为我的回答与大多数答案相同。