angular获取当前地址url

import { PlatformLocation } from '@angular/common';//PlatformLocation 与Location都可以,PlatformLocation 是子集
constructor(private location: PlatformLocation) {
}
for (const i in this.location) {
  if (i === 'location') {
    this.locationUrl = this.location[i].href;
    break;
  }
}

你可能感兴趣的:(前端)