vue項目報錯Navigating to current location ("/cancell") is not allowed

在這裏插入圖片描述
先截個圖,控制檯報錯如上。不影響功能,但是看着膈應。

百度了下,這個問題是由於連續點擊相同路由導致的。vue-router未處理這個問題。
解決方式
:自己捕捉錯誤
一、

this.$router.push(`/login`,()=>{},(err)=>{})

二 、

 this.$router.push(`/login`).catch(err=>{
            // console.warn(err);
          })

vue-router的API這樣定義的:vue-router

router.push(location, onComplete?, onAbort?)
router.push(location).then(onComplete).catch(onAbort)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章