Reputation: 28545
I have a method like this which is called on click, 2 params are passed:
selectOption(variantName, value) {
this.$router.push({ query: { variantName: value } })
}
If I call selectOption with variantName = "size", and value ="small"
I want the url to be something like /foo?size=small
at the moment it is something like ?variantName=size
Upvotes: 1
Views: 728
Reputation: 1
Since the key is dynamic you could wrap it by []
like :
this.$router.push({ query: { [variantName]: value } })
Upvotes: 2