vuejs/router

problem in watch query of route

mohamadkhalili opened this issue · 1 comments

Reproduction

https://codesandbox.io/p/sandbox/lively-breeze-xy5573?file=%2Fsrc%2FApp.vue

Steps to reproduce the bug

1- click on "names query 1"
2- check logs
3- click on "names query 2"
4- check logs

Expected behavior

I expected that no log would be displayed after clicking on "names query 2".

Actual behavior

In fact, it seems that the entire query element is watched, not the names element itself

Additional information

No response

Vue does some optimizations in watchers to avoid rerunning with the same value. In your case you have an array, so they are always different: [] !== []. Using a string or a computed of a string could help you achieve what you want.