添加新页面后我该怎么办? 我添加一个" TestPage"并修改了如下代码:
app.component.ts中的:
import { TestPage } from '../pages/TestPage/TestPagePage';
和:
this.pages = [
{ title: 'Page One', component: Page1 },
{ title: 'Page Two', component: Page2 },
{ title: 'Test Page', component: TestPage }
];
app.module.ts中的
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { Page1 } from '../pages/page1/page1';
import { Page2 } from '../pages/page2/page2';
import { TestPage } from '../pages/TestPage/TestPagePage';
@NgModule({
declarations: [
MyApp,
Page1,
Page2,
TestPage
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Page1,
Page2,
TestPage
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
但是,返回错误!!
"设备在935ms后准备就绪了#34; main.js
我该怎么办?我应该添加什么其他代码?
感谢
********** SOLUTION !!! ***********
Visual Studio生成错误代码!!当我添加一个新的离子页面(第3页),visual studio,在page3.ts
添加此代码 import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
/*
Generated class for the page3 page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-page3',
templateUrl: 'page3.html'
})
export class page3page {
constructor(public navCtrl: NavController, public navParams: NavParams) { }
ionViewDidLoad() {
console.log('ionViewDidLoad page3Page');
}
}
但是,这段代码运行良好(不是上面的代码):
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-page3',
templateUrl: 'page3.html'
})
export class Page3 {
constructor(public navCtrl: NavController) {
}
onLink(url: string) {
window.open(url);
}
}