How to set URL query params in Vue with Vue-Router

前端 未结 9 796
梦如初夏
梦如初夏 2020-12-23 20:24

I am trying to set query params with Vue-router when changing input fields, I don\'t want to navigate to some other page but just want to modify url query params on the same

9条回答
  •  北海茫月
    2020-12-23 20:36

    Here's my simple solution to update the query params in the URL without refreshing the page. Make sure it works for your use case.

    const query = { ...this.$route.query, someParam: 'some-value' };
    this.$router.replace({ query });
    

提交回复
热议问题