Angular路由修改原请求URL基础路径。
创始人
2024-10-28 05:00:32
0

我们可以使用useHash选项,将路由器配置为使用哈希标记来处理URL。在使用哈希标记时,Angular将忽略URL中的基础路径,以确保路由器正确解析。以下是示例代码:

在app.routing.module.ts中:

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

const routes: Routes = [
  { path: 'home', component: HomeComponent },
  { path: 'contact', component: ContactComponent },
  { path: '', redirectTo: '/home', pathMatch: 'full' }
];

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

在index.html中:




  
  MyApp
    // 将基础路径设置为空
  


  


使用以上代码设置路由器,将能正确解决Angular路由修改原请求URL基础路径的问题。

相关内容

热门资讯

透视课程!wepoker透视方... 透视课程!wepoker透视方法(透视)确实有辅助下载(哔哩哔哩)1、wepoker透视方法辅助软件...
透视演示!哈糖大菠萝有没有挂(... 透视演示!哈糖大菠萝有没有挂(透视)其实是有辅助安装(哔哩哔哩)哈糖大菠萝有没有挂脚本下载中分为三种...
透视方针!hhpoker有没有... 透视方针!hhpoker有没有外开挂(透视)原来是真的辅助工具(哔哩哔哩)一、hhpoker有没有外...
透视步骤!约局吧app有挂吗(... 透视步骤!约局吧app有挂吗(透视)其实是有辅助app(哔哩哔哩)1、约局吧app有挂吗免费脚本咨询...
透视窍门!wepoker怎么发... 透视窍门!wepoker怎么发冤家牌(透视)好像是有辅助神器(哔哩哔哩);1、透视窍门!wepoke...
透视机巧!werplan脚本(... 透视机巧!werplan脚本(透视)真是是真的辅助安装(哔哩哔哩)1、不需要AI权限,帮助你快速的进...
透视学习!大菠萝手游辅助(透视... 透视学习!大菠萝手游辅助(透视)真是是有辅助修改器(哔哩哔哩)1、进入游戏-大厅左侧-新手福利-激活...
透视策略!购买的wpk辅助在哪... 透视策略!购买的wpk辅助在哪里下载(透视)切实有辅助工具(哔哩哔哩)1、金币登录送、破产送、升级送...
透视妙计!wepoker代打辅... 透视妙计!wepoker代打辅助机器人(透视)一贯存在有辅助安装(哔哩哔哩)透视妙计!wepoker...
透视模板!wepoker私人局... 透视模板!wepoker私人局透视插件(透视)都是是有辅助app(哔哩哔哩)1)wepoker私人局...