如何在 url 中删除查询?

How to drop a query in a url?

我有以下 url:http://0.0.0.0:3000/book/all?my_query 如何放弃 "all?my_query" 并只留下 "book/" 我试图做这样的事情: if (this.$route.params.item === 'all') { this.$router.replace ('/') }

但它只是 returns 到主页

删除所有参数:

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

添加my_query参数:

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

只需删除查询对象的属性

    delete this.$route.query.my_query

解决方法如下:

$router.push($route.path)