【发布时间】:2021-05-24 19:32:50
【问题描述】:
我的 NuxtJS 应用程序中有一个接受查询参数的路由。我正在尝试实现允许用户更改查询参数并重新加载页面的逻辑。
我试过了:
// this does not work because I'm already in "mypage" and "push" does not reload the same page
this.$router.push(`/mypage?param1=${value1}¶m2=${value2}`)
// same result as above
this.$router.push({ path: '/mypage', query: {param1: value1, param2: value2}})
// this is able to change the query parameters but on reload they are reverted to the originals
this.$router.replace({ query: {param1: value1, param2: value2} })
window.location.reload()
// This reload the page but the query parameters are reverted as well
this.$router.go(`/mypage?param1=${value1}¶m2=${value2}`)
有什么建议吗?
【问题讨论】:
-
使用
reload的目的是什么? -
更改查询参数后刷新页面但不起作用
-
但是 Vue 是响应式的,应该预期更改会在不刷新的情况下发生。这不是一个好习惯
标签: vue.js vue-router server-side-rendering nuxtjs