具有特定格式的角检查URL

问题描述 投票:0回答:1

我想检查我的URL的格式完全是特定。我有这个网址

www.example.com?rt=12365

我要检查收入URL是否具有以下格式

?rt= number

然后做点什么。我像下面的代码一样使用路由器:

const queryParams = router.url

但是我不知道如何进行检查。我是打字和棱角字的新手,请帮助我

angular typescript url angular-router
1个回答
0
投票

尝试此

 constructor(private route: ActivatedRoute) {

 }

 if (this.route.snapshot.queryParams['rt']) {

 }

希望对您有用

© www.soinside.com 2019 - 2024. All rights reserved.