我对 ionic 很陌生,并且有一个简单的问题,令我惊讶的是,我在搜索的任何地方都找不到我的答案。
我想要的是像这样实现简单的页面导航: https ://ionicframework.com/docs/api/nav
手机下方的源代码提供了 javascript 代码,但我想要 angular/ionic 代码。
任何其他文档都使用复杂的代码,由于某种原因我无法理解。
我如何使用最简单的 IONIC-5/Angular 代码(使用“ion-nav”)来归档这个目标?
HTML:
这就是我到目前为止所做的:
<ion-nav root="rootPage">
<ion-header translucent>
<ion-toolbar>
<ion-title>Nav</ion-title>
</ion-toolbar>
</ion-header>
<ion-content fullscreen>
<ion-list *ngFor="let page of techs">
<ion-item button (click)="showDetail(page)">
<ion-label>
<h3>{{page.title}}</h3>
</ion-label>
</ion-item>
</ion-list>
</ion-content>
</ion-nav>
TS:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-list',
templateUrl: './list.page.html',
styleUrls: ['./list.page.scss'],
})
export class ListPage implements OnInit {
constructor() { }
ngOnInit() {
}
rootPage:any;
techs = [
{
'title': 'Angular',
'icon': 'angular',
'description': 'A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.',
'color': '#E63135'
},
{
'title': 'CSS3',
'icon': 'css3',
'description': 'The latest version of cascading stylesheets - the styling language of the web!',
'color': '#0CA9EA'
},
{
'title': 'HTML5',
'icon': 'html5',
'description': 'The latest version of the web\'s markup language.',
'color': '#F46529'
},
{
'title': 'JavaScript',
'icon': 'javascript',
'description': 'One of the most popular programming languages on the Web!',
'color': '#FFD439'
},
{
'title': 'Sass',
'icon': 'sass',
'description': 'Syntactically Awesome Stylesheets - a mature, stable, and powerful professional grade CSS extension.',
'color': '#CE6296'
},
{
'title': 'NodeJS',
'icon': 'nodejs',
'description': 'An open-source, cross-platform runtime environment for developing server-side Web applications.',
'color': '#78BD43'
},
{
'title': 'Python',
'icon': 'python',
'description': 'A clear and powerful object-oriented programming language!',
'color': '#3575AC'
},
{
'title': 'Markdown',
'icon': 'markdown',
'description': 'A super simple way to add formatting like headers, bold, bulleted lists, and so on to plain text.',
'color': '#412159'
},
{
'title': 'Tux',
'icon': 'tux',
'description': 'The official mascot of the Linux kernel!',
'color': '#000'
},
];
showDetail(page:any){
const tech = techs.find(tech => tech.title === title);
nav.push('nav-detail', { tech });
}
}
PS:nav.push('nav-detail', { tech });
给出错误(我不知道这里的导航是什么)