问题描述
我想看到网址上的实际路线,但我无法确定我需要更改的内容。
I want to see the actual route on the url but I can't figure out what I need to change exactly.
我在这里关注文档:
I'm following the docs here: https://ionicframework.com/docs/api/navigation/IonicPage/
但我收到此错误:
@IonicPage({
name: 'sums-home',
segment: 'sums-home'
})
我使用以下代码创建了home.module.ts文件:
I created the home.module.ts file with this code:
import { NgModule } from '@angular/core';
从'./home'导入{SumsHomePage};来自'ionic-angular'的
import {IonicPageModule};
import { SumsHomePage} from './home';import { IonicPageModule } from 'ionic-angular';
import { NgModule } from '@angular/core';
import { SumsHomePage} from './home';
import { IonicPageModule } from 'ionic-angular';
@NgModule({
declarations: [
SumsHomePage
],
imports: [
IonicPageModule.forChild(SumsHomePage),
],
exports: [
SumsHomePage
]
})
export class SumsHomePageModule { }
我转到此页面:
this.navCtrl.push('sums-home');
但我认为应该还有别的东西。
but I think it should have something else.
有人存档吗?
推荐答案
我的桌面离子项目遇到了同样的问题,发现这个解决方案使用了 DeepLinks :
i was having the same problem on my Desktop Ionic project, and found this solution using DeepLinks :
导入:[
BrowserModule,
IonicModule.forRoot(MyApp,{ },{
链接:[
{component:HomePage,name:'Home',segment:'home'},
{component:LoginPage,name:'Login',segment:' login'},
{component:UsersPage,name:'Users',segment:'users'},
{component:TrophiesPage,name:'Trophies',segment:'trophies'}
]
}),
HttpModule,
LoginPageModule,
UsersPageModule,
TrophiesPageModule,
TranslateModule.forRoot({
loader:{
提供:TranslateLoader,
useFactory :( createTransla teLoader),
deps:[Http]
}
}),
]
注意 IonicModule.forRoot 导入中使用的链接属性。
现在当我使用:
Just notice links property used in IonicModule.forRoot import.Now when i use:
this.navCtrl.setRoot(HomePage);
我被正确地重定向到网址。
希望它会有所帮助。和平
I get correctly redirected to url "http://localhost:8100/#/home".Hope it'll help. Peace
这篇关于无法在Ionic 3上创建路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!