Angular路由跳转外部URL

新建redirectComponent.ts文件:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'redirect',
  template: 'redirecting...'
})
export class RedirectComponent implements OnInit {
  constructor() { }

  ngOnInit() {
    window.location.href = 'http://www.redirecturl.com'
  }
}

并在你的路由中使用它:

{ path: 'login', component: RedirectComponent, pathMath: 'full'},

你可能感兴趣的:(Angular)