账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    Angular 4.0 路由“找不到指定页面”无法匹配
    60
    0

    打扰各位了,之前有问过,没有解决。

    错误提示:ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'login'

    在网上查了许久,一般都是回答,将路由设置为:path: '',但当前已经如此。
    在 stackoverflow 上也有几个例子,都不尽相同。最终未解决"貌似不大的问题"。

    上传了文件(删除了node_modules)

    链接: https://pan.baidu.com/s/133H5... 密码: qaqd

    详细原贴:
    https://segmentfault.com/q/10...

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 队友在哪 普通会员 1楼

      在Angular 4.0中,如果遇到路由提示“找不到指定页面”或无法匹配路由的情况,可能是以下几个原因:

      1. 路由配置不正确:请确保你在app-routing.module.ts或其他相应的路由模块中已经为该页面定义了路由。例如:

      ```typescript import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { YourComponent } from './your.component';

      const routes: Routes = [ { path: 'your-path', component: YourComponent }, ];

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

      1. 链接路径错误:检查在HTML模板中引用该路由的链接是否正确。应如下所示:

      html <a routerLink="/your-path">前往你的页面</a>

      1. 子路由未正确嵌套:如果你的组件是子路由的一部分,那么需要在父路由配置中嵌套声明。例如:

      typescript const routes: Routes = [ { path: 'parent', component: ParentComponent, children: [ { path: 'your-path', component: YourComponent }, ] }, ];

      1. 模块导入问题:确保包含目标组件的模块已经被正确的导入到主模块或者其他相关模块中。

      2. URL地址栏直接输入:如果是通过刷新页面或者直接在地址栏输入URL访问,则还需要在index.html中配置使用 <base href="/"> ,以便于Angular能够正确解析路由。

      以上是常见的一些问题和解决方案,具体问题可能需要根据实际情况进行排查。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部