Angular 2 将数组传递给路由器 queryString [英] Angular 2 pass array to router queryString

查看:27
本文介绍了Angular 2 将数组传递给路由器 queryString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数组 ids: [1, 2, 3] 传递给路由器查询字符串,如下所示:http://...some-url?ids=1&ids=2&ids=3,但是当我尝试使用

I would like to pass an 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 a way to add query params with the 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆