无法在Ionic 3上创建路线 [英] Cannot create routes on Ionic 3

查看:145
本文介绍了无法在Ionic 3上创建路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看到网址上的实际路线,但我无法确定我需要更改的内容。

I want to see the actual route on the url but I can't figure out what I need to change exactly.

我在这里关注文档: https://ionicframework.com/docs/api/navigation/IonicPage/

I'm following the docs here: https://ionicframework.com/docs/api/navigation/IonicPage/

但我收到此错误:


... home.ts有一个@IonicPage装饰,但它没有
a对应的NgModule在...
我在页面顶部有这个:

...home.ts has a @IonicPage decorator, but it does not have a corresponding "NgModule" at... I have this on the top of my page:



@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);

我被正确地重定向到网址 http:// localhost:8100 /#/ home
希望它会有所帮助。和平

I get correctly redirected to url "http://localhost:8100/#/home". Hope it'll help. Peace

这篇关于无法在Ionic 3上创建路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆