Vue deletes individual parameters in the query or clears the query

There is a requirement involved in the process of writing the project. It can be roughly described as an edit pop-up window when entering for the first time. If you click the save button of the edit pop-up window and refresh the page, the pop-up window will no longer pop up.

Suppose there is a parameter of type open

let resolves = this.$router.resolve({
  name: 'OrdersDetail',
  query: {
    orderId: this.orderId,
    channel: this.salesChannel,
    type: 'open' // 目标参数
  }
})
window.open(resolves.href, '_blank')

remove the type parameter

let newQuery = JSON.parse(JSON.stringify(this.$route.query)) // 先拷贝一个一模一样的对象
delete newQuery.type //再删除page
this.$router.replace({ query: newQuery }) //再把新的替换了

Delete all query parameters

let path = this.$route.path //先获取路由路径
this.$router.replace(path) //再跳转路由路径,query参数没带过去,所以被清除了

or

this.$router.replace({ query: {} });

Guess you like

Origin blog.csdn.net/weixin_43743175/article/details/127670035