Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] router.go support object-style query string #365

Closed
gouflv opened this issue Feb 8, 2016 · 9 comments
Closed

[Feature] router.go support object-style query string #365

gouflv opened this issue Feb 8, 2016 · 9 comments

Comments

@gouflv
Copy link

gouflv commented Feb 8, 2016

object-style query string maybe a good idea on store some object to query without merge then,
just like jquery.param() do:
obj = { a: { one: 1, two: 2, three: 3 } }==> a[one]=1&a[two]=2&a[three]=3

@paulohp
Copy link

paulohp commented Mar 16, 2016

@yyx990803 is there someone implementing this? How can I help?

@agonbina
Copy link

@paulohp the qs library supports this, maybe see how it's implemented there and submit a PR? :)

@cve
Copy link

cve commented Jun 28, 2016

I'm working on advanced data-table component and this functionality is "must have", cause I want to implement saving state of filters and pagination in query strings

@seaneagan
Copy link

seaneagan commented Feb 14, 2017

vue-resource does this. Perhaps vue-resource and vue-router should shared a common vue-url module or similar?

@yyx990803
Copy link
Member

@seaneagan this issue is for 0.7 and is outdated. 2.x already supports this.

@seaneagan
Copy link

seaneagan commented Feb 14, 2017

It looks like the latest code does support Arrays, but with ?foo=1&foo=2 rather than ?foo[]=1&foo[]=2 (like vue-resource), and it doesn't support objects e.g. ?foo[a]=1&foo[b]=2&foo[c]=3 (like vue-resource), you will instead get e.g. ?foo=[object Object]

@posva posva added the 1.x label Feb 14, 2017
@posva posva closed this as completed Jul 9, 2018
@Danita
Copy link

Danita commented Jul 13, 2018

Why is this closed? Is this a "wontfix"? As of vue-router@3.0.1 is still unsolved:

{ "filter": { "title": "bla", "actions": 1 } }

returns

?filter=%5Bobject%20Object%5D

Are there any official workarounds?

@posva
Copy link
Member

posva commented Jul 13, 2018

in vue-router 3 you have to provide a custom and more powerful query parser (like https://github.com/ljharb/qs) to vue-router: https://router.vuejs.org/api/#parsequery-stringifyquery

@Danita
Copy link

Danita commented Jul 13, 2018

Thanks, I just found #1259 with the explanation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants