2

i have three different route-link and i want when you click on each of them ,

a value query added to other queries

<router-link append to="{query:{ color : 'red' }" >color</router-link> => ex.com/product?color=red
<router-link append to="{query:{ size: 2 }" >size</router-link> => ex.com/product?color=red&&size=2
<router-link append to="{query:{ men: true }" >men</router-link> => ex.com/product?color=red&&size=2&&men=true

the problem is that when you click each of them new query replace other

but i want it to append with other queries

so , how can i do it ?

morteza mortezaie
  • 1,002
  • 14
  • 37

1 Answers1

1

You have to extend the existing query object yourself:

<router-link append :to="{ query: { ...$route.query, color: 'red' } }">
                                    ^^^^^^^^^^^^^^^
Decade Moon
  • 32,968
  • 8
  • 81
  • 101