Angular路由不起作用(错误:无法找到网站)。
创始人
2024-10-28 01:00:13
0
  1. 确认路由模块是否正确导入到应用中,例如:

import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './home/home.component'; import { AboutComponent } from './about/about.component';

const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'about', component: AboutComponent } ];

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

  1. 确认应用是否设置了基本URL,例如:

import { Component } from '@angular/core'; import { Router } from '@angular/router';

@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { constructor(private router: Router) { this.router.navigate(['/']); } }

  1. 如果项目位于子目录中,请使用相对URL,例如:

Product

  1. 如果URL中包含特殊字符,请使用encodeURIComponent()编码,例如:

let id = '123#456' this.router.navigate(['/product', encodeURIComponent(id)]);

通过以上操作可以解决Angular路由不起作用的错误。

相关内容

热门资讯

透视教程!hhpoker免费透... 透视教程!hhpoker免费透视脚本,来玩德州破解器,攻略方法(总是是有挂)是一款可以让一直输的玩家...
透视好友房!wpk透视辅助软件... 透视好友房!wpk透视辅助软件,wepoker永久免费脚本,大神讲解(原生存在有挂)1、玩家可以在w...
透视中牌率!wpk辅助购买,w... 透视中牌率!wpk辅助购买,wepoker软件靠谱么,揭秘教程(竟然是真的有挂);(需添加指定Q群1...
透视了解!wepoker透视底... 透视了解!wepoker透视底牌脚本,德普之星透视辅助软件,微扑克教程(都是是真的有挂);致您一封信...
透视系统!wpk透视表,wep... 透视系统!wpk透视表,wepoker辅助器有哪些功能,专业教程(原生真的是有挂);揭秘教程安装方法...
透视教学!wpk辅助器,wep... 透视教学!wpk辅助器,wepoker轻量版透视系统,必赢方法(原生有挂);原来确实真的有挂(需添加...
透视透视挂!智星菠萝辅助怎么买... 透视透视挂!智星菠萝辅助怎么买,we poker辅助器下载,wpk教程(一直真的是有挂);最新版20...
透视工具!wepoker脚本下... 透视工具!wepoker脚本下载,wepoker公共底牌,解密教程(都是真的是有挂);精心打造了俱乐...
透视代打!aapoker辅助包... 透视代打!aapoker辅助包,wepoker透视脚本苹果版,必赢教程(总是是有挂)1、完成wepo...
透视脚本!wpk辅助器是真的吗... 透视脚本!wpk辅助器是真的吗,hhpoker软件靠谱吗,揭秘教程(从前真的有挂)是一款可以让一直输...