解决方法:
1.在路由文件index.js
{
path: '/ProductIntroduction',
name: 'ProductIntroduction',
component: function(){
return import('../views/ProductIntroduction.vue').catch(err => err)
},
},
添加catch(err => err)即可。
2.同样在路由文件index.js
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
添加这段文本。
注意:VueRouter这个关键字是上面你引用路由的名称
比如:import VueRouter from 'vue-router'