Skip to content

Commit 8210b0d

Browse files
committed
update watch source default to route query and params not fullPath to avoid triggering on anchor
1 parent 942f1af commit 8210b0d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export const gReactive = resetableReactive // alias
3636
export const whenRouteChange = (callback: () => void, watchSource?: () => unknown) => {
3737
const route = useRoute()
3838
const routeName = route.name // cache route name
39+
const watchRouteParamsAndQuery = () => JSON.stringify([route.query, route.params])
3940
watch(
40-
watchSource ?? (() => route.fullPath),
41+
watchSource ?? watchRouteParamsAndQuery,
4142
() => {
4243
if (route.name === routeName) {
4344
callback()

0 commit comments

Comments
 (0)