Skip to content

$route.query can't use in vue-resource params. #873

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

Closed
alphatr opened this issue Nov 4, 2016 · 5 comments
Closed

$route.query can't use in vue-resource params. #873

alphatr opened this issue Nov 4, 2016 · 5 comments

Comments

@alphatr
Copy link

alphatr commented Nov 4, 2016

I use $route.query in vue-resource like this:

Vue.http.get('/someUrl', {query: $route.query});

and receive a obj.hasOwnProperty is not a function error;

I find in vue-route create query by using Object.create(null) and this is completely blank object, no inherit hasOwnProperty method.

however in vue-resource, it can use obj.hasOwnProperty in each function to transform the params query.

@posva
Copy link
Member

posva commented Nov 5, 2016

As a workaround until this is fixed, you can use the assign syntax: query: {...$route.query}

@yusank
Copy link

yusank commented Dec 20, 2017

http://example.com?a=1&b=2&c=3

I want to change one of the param value and still use it like

query: {
...$route.query
}

any ideas?

@posva
Copy link
Member

posva commented Dec 20, 2017

you just do

query: {
  ...$route.query,
  myOverridenValue: 'hi'
}

Remember you can use the forum or the Discord server to ask quick questions 🙂

@yusank
Copy link

yusank commented Dec 20, 2017

OK , thank you . I just start learning Vue ,so I didn't know those websites before you told me . 👀

@JounQin
Copy link
Contributor

JounQin commented Dec 20, 2017

It's nothing related to Vue, it is just js (or es?).

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

5 participants