杂七杂八(1) - Angular获取当前浏览器地址及相关信息

mac2025-01-27  31

在constructor中添加location: PlatformLocation import {PlatformLocation} from '@angular/common'; constructor( private location: PlatformLocation, ) {} ngOnInit() { console.info(this.location); //一个大的内容 console.info(this.location['location']); //是PlatformLocation中的子级,里面有浏览器地址等真正需要的内容。 }

最新回复(0)