Vuejs2 在没有导航复制的情况下,如何使用vue路由器进行筛选

Vuejs2 在没有导航复制的情况下,如何使用vue路由器进行筛选,vuejs2,vue-router,Vuejs2,Vue Router,在我的剧本里 <template> <div > home page <button @click="queryMaking"> query making</button> </div> </template> <script> export default { data() { return { querys: [] } }, method

在我的剧本里

<template>
 <div >
   home page
  <button @click="queryMaking"> query making</button>
 </div>
</template>

<script>
 export default {
  data() {
   return {
     querys: []
   }
  },
  methods: {
   queryMaking(){
     this.querys.push("chemical")
     this.$router.push({
       name: 'home', query: {subject: this.querys}
     })
   }
  },
 created(){
   if (typeof this.$route.query.subject === 'string'){
     this.querys = [this.$route.query.subject]
   }else{
     this.querys = this.$route.query.subject
   }
 }
}
</script>

主页
提问
导出默认值{
数据(){
返回{
查询:[]
}
},
方法:{
查询{
这个.querys.push(“化学”)
这是$router.push({
名称:'home',查询:{subject:this.querys}
})
}
},
创建(){
if(此的类型。$route.query.subject=='string'){
this.querys=[this.$route.query.subject]
}否则{
this.querys=this.$route.query.subject
}
}
}

当我转到链接时:http://localhost:8080/?subject=math&subject=physical. 然后查询另一个主题,我得到“NavigationDuplicated:避免了到当前位置的冗余导航”。如果我去链接http://localhost:8080/ 或在url中使用1个查询http://localhost:8080/?subject=math 我没有得到任何错误。所以,我需要帮助。对不起我的英语。提前感谢

您应该像这样捕捉错误:

this.$router.push({
名称:'home',查询:{subject:this.querys}
}).catch(()=>true);

我尝试过,但我想修复此错误,因此您不应两次导航到同一路线。