gpt4 book ai didi

angular - 如何在 IONIC 4 中设置 rootPage

转载 作者:行者123 更新时间:2023-11-28 02:25:12 25 4
gpt4 key购买 nike

这就是我现在所拥有的,但似乎真的无法找到我的问题的正确答案我到处都看过所以也许知道的人可以帮助我?。我如何将 ionic 3 中的 RootPage 设置为 Ionic 4,因为我尝试了一切,这就是尝试的结果

import {Component, ViewChild} from '@angular/core';
import {NavController, Platform} from '@ionic/angular';
import {SplashScreen} from '@ionic-native/splash-screen/ngx';
import {StatusBar} from '@ionic-native/status-bar/ngx';
import {Router} from '@angular/router';
import {GettingStartedPage} from './getting-started/getting-started.page';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
})

export class AppComponent {
@ViewChild(NavController) nav: NavController;
rootPage;


constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private NavCtrl: NavController) {
this.initializeApp();
}

// Eindigt constructor

initializeApp() {
this.platform.ready().then(() => {
this.splashScreen.hide();
// set status bar naar onze app kleur
this.statusBar.backgroundColorByHexString('#E84B56');
});
}

openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.rootPage.navigateRoot('/getting-started');

}
}

最佳答案

从 Ionic 4 开始,您可以使用 Angular Routing。如果你想要/getting-started要成为您的根页面,请进入 app-routing.module.ts并编辑路线。如果您没有,请创建一个指向您的页面的路由,并使用 path: '' 重定向该页面。至 /getting-started .

最后一个app-routing.module.ts可能是:

const routes: Routes = [
{path: '', redirectTo: 'getting-startet', pathMatch: 'full'}, //Root Path redirect to your getting-started path
{path: 'getting-started', loadChildren: './getting-started/getting-started.module#GettingStartedPageModule'}, // when hit the getting-startet path, load the page
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}

关于angular - 如何在 IONIC 4 中设置 rootPage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54675140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com