I'm currently working on updating query parameters using Vue-router as I change input fields. My goal is to adjust the URL query parameters without navigating to a different page, but only modifying them on the current page. This is how I am approaching it:
this.$router.replace({ query: { q1: "q1" } })
However, this action also results in the page being refreshed and the vertical position resetting to 0, causing it to scroll back to the top. Is there a correct method for setting URL query parameters or perhaps a more efficient way to achieve this?
Update:
This is the code snippet from my router configuration:
export default new Router({
mode: 'history',
scrollBehavior: (to, from, savedPosition) => {
if (to.hash) {
return {selector: to.hash}
} else {
return {x: 0, y: 0}
}
},
routes: [
.......
{ path: '/user/:id', component: UserView },
]
})