国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

vue-router.esm.js?a12b:2046 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation

這篇具有很好參考價(jià)值的文章主要介紹了vue-router.esm.js?a12b:2046 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

報(bào)錯(cuò)信息

vue-router.esm.js?a12b:2046 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/home".

vue-router.esm.js?a12b:2046 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation

?

報(bào)錯(cuò)原因:重復(fù)點(diǎn)擊路由導(dǎo)致,因?yàn)関ue-router引入了promise,當(dāng)我們使用this.$router.push時(shí)候需要多添加成功或失敗的回調(diào),否則就會報(bào)出以上的錯(cuò)誤。

原代碼

vue-router.esm.js?a12b:2046 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation

?解決辦法

第一種

? ? ? ? 在進(jìn)行路由跳轉(zhuǎn)時(shí)對路徑進(jìn)行判斷如果重復(fù)即不再執(zhí)行

????????

			switchTab(path) {
				if (this.$router.path == path) return
				this.$router.push(path)
			}

第二種

? ? ? ? 跳轉(zhuǎn)后使用catch語句對錯(cuò)誤不再進(jìn)行處理

this.$router.push(path).catch(err => {})

第三種

? ? ? ? 基于第二種方法,當(dāng)我們的路由跳轉(zhuǎn)過多時(shí)就需要每次跳轉(zhuǎn)都要加上catch回調(diào),這樣比較麻煩,所以還可以在引入vueRouter文件下重寫push和replace方法


import VueRouter from 'vue-router';
//保存原型對象的Push
let originPush = VueRouter.prototype.push
let originReplace = VueRouter.prototype.replace
//重寫push方法
VueRouter.prototype.push = function (location, res, rej) {
  if (res && rej) {
    originPush.call(this, location, res, rej)
  }
  else {
    originPush.call(this, location, () => { }, () => { })
  }
 
}
//重寫replace方法
VueRouter.prototype.replace = function (location, res, rej) {
  if (res && rej) {
    originReplace.call(this, location, res, rej)
  }
  else {
    originReplace.call(this, location, () => { }, () => { })
  }
} 

csdn文章推薦受影響解決辦法10個(gè)字10行文章來源地址http://www.zghlxwxcb.cn/news/detail-403836.html

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

csdn文章推薦受影響解決辦法10個(gè)字10行

到了這里,關(guān)于vue-router.esm.js?a12b:2046 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包