Vue · Middle · Question 62 of 75
How do you keep filters in the URL query and react to their changes?
const route = useRoute()
watch(() => route.query.status, (status) => load(status))
router.push({ query: { ...route.query, status: 'open' } })- ✓Correct answer: Read
route.query, watch it with a getter and update it viarouter.push/replace - 2Store the filters in
localStorageonly - 3Query parameters aren't reactive
Explanation
URL state survives reloads and can be shared. Query values are strings (or arrays) and need parsing.