先截個圖,控制檯報錯如上。不影響功能,但是看着膈應。
百度了下,這個問題是由於連續點擊相同路由導致的。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)