router.push 的语法规则如下:
- router.push(location(导航路径), onComplete(成功的回调)?, onAbort?(失败的回调))
- router.push(location).then(onComplete).catch(onAbort)
router.replace 的语法规则如下:
- router.replace(location, onComplete?, onAbort?)
- router.replace(location).then(onComplete).catch(onAbort)
解决方案一:
methods: {
//执行 toSearch() 方法后,跳转路由
toSearch(){
this.$router.push('/search') //————重复点击会报错:NavigationDuplicated
//解决方法如下:
this.$router.push('/sear