Angular前置渲染重定向带有额外斜杆
创始人
2024-10-29 03:30:22
0

您可以在 Angular 的“routes”数组中,为PrerenderController添加一个“Path Location Strategy”,然后在“index.html”文件中添加一个重定向标签,将所有具有额外斜杆的请求重定向到没有斜杆的URL。以下是示例代码:

在app.module.ts中,为PrerenderController添加PathLocationStrategy:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LocationStrategy, PathLocationStrategy } from '@angular/common';
import { PrerenderController } from './prerender';

@NgModule({
  imports: [BrowserModule],
  providers: [
    { provide: LocationStrategy, useClass: PathLocationStrategy },
    PrerenderController
  ]
})
export class AppModule { }

在 "index.html" 文件中添加重定向标记:




  
  My App
  
  
  
  


  


在这个代码示例中,我们将重定向标签插入到了“index.html”中。如果页面的URL以“//”结尾,重定向标签会将页面重定向到没有斜杆的URL。例如,将会把"example.com//"重定向到"example.com"。

相关内容

热门资讯

德州ai人工智能!德州辅助dt... 德州ai人工智能!德州辅助dto,德扑之星真是有挂(详细有外 挂教程)1、实时德州ai人工智能开挂更...
wpk透视辅助!wpK一贯真的... wpk透视辅助!wpK一贯真的有挂,wpK都是真的有挂,必胜教程(有挂解说);wpk辅助器中分为三种...
aapoker发牌机制!wep... aapoker发牌机制!wepoke透明真的,x-poker辅助软件(详细透视教程);致您一封信;亲...
wepower辅助器!wopo... wepower辅助器!wopoker辅助软件,wepower德州扑克,必备教程(有挂解密);原来确实...
德州之星有外 挂!德州ai智能... 德州之星有外 挂!德州ai智能系统,智星德州确实是有挂(详细免费辅助神器app教程)1)德州之星有外...
wpk俱乐部!wPk总是真的有... wpk俱乐部!wPk总是真的有挂,WpK其实真的有挂,切实教程(有挂规律);1、这是跨平台的wpk黑...
aapoker透明挂!wpk德... aapoker透明挂!wpk德州胜利跟号有关,wepoke软件透明是真的(详细辅助挂教程)关于aap...
揭秘教程!wepoke支持安卓... 揭秘教程!wepoke支持安卓(we辅助poker德之星)德州wepower(原来真的有挂)准备好在...
德扑之星辅助器购买!德州之星a... 德扑之星辅助器购买!德州之星ai辅助,nzt德州总是真的是有挂(详细数据软件教程)是一款可以让一直输...
wpk有外 挂!wpk机器人代... wpk有外 挂!wpk机器人代打,WpK一直真的有挂,详细教程,(有挂揭秘)1、上手简单,内置详细流...