gpt4 book ai didi

angular - Angular 5 中 Angular @angular/http URLSearchParams 类的替代品是什么

转载 作者:行者123 更新时间:2023-12-01 22:09:04 28 4
gpt4 key购买 nike

我目前正在使用@angular/http URLSearchParams 类来检索 URL 参数。在 Angular 5 中,注意到这已被弃用,但我没有看到以我当前使用的方式替换 URLSearchParams 的合适类。

constructor() { 
this.urlSearchParams = new URLSearchParams(window.location.search.substring(1));
this.custno = this.urlSearchParams.get('custno');
this.plan = this.urlSearchParams.get('plan');
}

注意:我没有使用 appRoutingModule,因为它对我正在创建的 SPA 来说太过分了。

在此上下文中替换@angular/common/http URLSearchParams 类的正确解决方案是什么?

最佳答案

替换为 HttpParams

import { HttpParams } from '@angular/common/http';

Official docs from angular.

关于angular - Angular 5 中 Angular @angular/http URLSearchParams 类的替代品是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49559051/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com