vue - 对于相同路径的跳转,不要在控制台中报错 Avoided redundant navigation to current location
访问量: 1194
代码:
import VueRouter from 'vue-router' /** * 对于相同路径的跳转,不要在console中报错. */ const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => { if ( err.name !== 'NavigationDuplicated' && !err.message.includes('Avoided redundant navigation to current location') ) { logError(err); } }) } /* eslint-disable no-new */ new Vue({ components: { App }, router, store, template: '' }).$mount('#app')