Angular 2将数组传递给路由器queryString [英] Angular 2 pass array to router queryString
本文介绍了Angular 2将数组传递给路由器queryString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将数组ids: [1, 2, 3]
传递给路由器查询字符串,例如:http://...some-url?ids=1&ids=2&ids=3
,但是当我尝试使用
I would like pass array ids: [1, 2, 3]
to router query string like this: http://...some-url?ids=1&ids=2&ids=3
, but when I try to use
const queryParams = { ids: [1, 2, 3] };
this.router.navigate(['/some-route'], { queryParams });
结果是http://...some-url/some-route?ids=1%2C2%2C3
是否可以使用相同的键添加查询参数?
Is there way to add query params with same key?
推荐答案
好像路由器中有错误. 请检查以下答案: https://stackoverflow.com/a/42505212/7634393
Looks like there is a bug in the router. Please, check this answer: https://stackoverflow.com/a/42505212/7634393
这篇关于Angular 2将数组传递给路由器queryString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文