Angular2 + Cordova - 启动时无法匹配任何路由 [英] Angular2 + Cordova - Cannot match any routes on startup

查看:185
本文介绍了Angular2 + Cordova - 启动时无法匹配任何路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Angular2应用程序的问题,当我为Android构建它(也许这个问题也发生在iOS上,但我还没有测试它)。在启动时我收到以下错误信息:

I've got a problem with a Angular2 app, when I build it for Android (maybe this problem also occurs on iOS, but I didn't tested it yet). On startup I get the following error message:

EXCEPTION: Error: Uncaught (in promise): Cannot match any routes. Current segment: 'android_asset'. Available routes: ['', '/login', '/register', '/lostpw', '/resetpw', '/content'].

由于应用程序的启动页面无法加载。要使应用程序运行,我不得不替换index.html中的base-tag从

Due to that the startpage of the app fails to load. To make the app running at all I had to replace the base-tag in the index.html from

 <base href="/">

 <base href="file:///android_asset/www/" target="_blank">

但是如上所述,现在路由器尝试解析android_asset。在应用程序中,我可以点击菜单项如

But as said, now the router tries to resolve android_asset. With in the app I can click on a menu-entry like

 <a [routerLink]="['/']">Home</a>

,我已成功重定向到首页路线。

and I am successfully redirected to the home route.

有没有人知道如何在启动时解决问题?

Does anybody know how to solve the problem on the startup?

版本:Angular 2.0.0-rc.1

Version: Angular 2.0.0-rc.1

推荐答案

对于''redirct to home

For '' redirct to home

export const StartRoutes:RouterConfig =
{
path:'',
redirectTo:'/ home'
}
];

这篇关于Angular2 + Cordova - 启动时无法匹配任何路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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