我正在使用WordPress后端创建ionic 3应用程序。这是我的代码
import { Component } from '@angular/core';
import { NavController, NavParams, LoadingController } from "ionic-angular";
import { ViewController } from 'ionic-angular';
import { WordpressProvider } from './../../providers/wordpress/wordpress';
import { PostPage } from './../../pages/post/post';
@Component({
selector: 'page-blog',
templateUrl: 'blog.html',
})
export class BlogPage {
posts: any = [];
private loading: any;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public wordpress: WordpressProvider,
public loadingCtrl: LoadingController,
public viewCtrl: ViewController,
) {
this.loading = this.loadingCtrl.create();
this.loading.present();
}
ionViewDidLoad() {
console.log('ionViewDidLoad BlogPage');
this.wordpress.retrievePosts().subscribe(results => {
this.posts = results;
this.loading.dismiss();
});
}
openPostPage(post) {
this.navCtrl.push(PostPage, {"post": post});
}
}
现在我调用标题
<ion-header>
<ion-toolbar color="white_bg">
<ion-buttons left>
<button ion-button (click)="viewCtrl.dismiss()">
<ion-icon name="arrow-back"></ion-icon>
</button>
</ion-buttons>
<ion-title center toolbar-title><img src="./assets/images/logo.png" class="logo"/></ion-title>
<ion-buttons end>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
</ion-buttons>
</ion-toolbar>
</ion-header>
这给了我这个错误
运行时错误未捕获(承诺(:导航堆栈至少需要一个根页面
谁能指出出了什么问题?
你的应用程序怎么样.html?这是你的应用程序的主要视图。应该有这样的东西:
<ion-nav [root]="rootPage"></ion-nav>
它定义了您的根视图,这是rootPage
,并在您的main.ts
中设置您的根页面。