我在Ionic 2框架中非常新。我想知道,我如何使用网址在离子应用程序中导航。类似的方式导航是在Angular 2应用程序中完成的。Ionic 2:使用URL导航
比方说,我想有本地主机IntroPage:8100 /前奏与登录按钮并按下按钮后,我想重定向到首页上本地主机:8100 /家。
localhost:8100/intro -> localhost:8100/home
我在Ionic 2框架中非常新。我想知道,我如何使用网址在离子应用程序中导航。类似的方式导航是在Angular 2应用程序中完成的。Ionic 2:使用URL导航
比方说,我想有本地主机IntroPage:8100 /前奏与登录按钮并按下按钮后,我想重定向到首页上本地主机:8100 /家。
localhost:8100/intro -> localhost:8100/home
您可以使用ionic2的DeepLinker。
在ionic2中,您可以使用this.navigator.push(SomeComponent)
进行导航。但是,如果您想要更改网址,您需要为它们定义deeplinker,例如:
imports: [
IonicModule.forRoot(MyApp, {}, {
links: [
{ component: HomePage, name: 'Home', segment: 'home' }
]
})
]
的文件说:(https://ionicframework.com/docs/v2/api/navigation/NavController/
) 你仍然不能使用UI-S参考样离子1..but仅this.navigation.push(“家”)......这意味着你必须做在HTML(可能是(点击)= “MYFUNC()”)函数来调用导航TS文件
import { Component, ViewChild } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
template: '<ion-nav #myNav [root]="rootPage"></ion-nav>'
})
export class MyApp {
@ViewChild('myNav') nav: NavController
public rootPage = TabsPage;
// Wait for the components in MyApp's template to be initialized
// In this case, we are waiting for the Nav with reference variable of "#myNav"
ngOnInit() {
// Let's navigate from TabsPage to Page1
this.nav.push('home');
}
}