在main.js里面加上以下代码即可
import Router from ‘vue-router’;
const routerReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
return routerReplace .call(this, location).catch(error=> error)
};
注::如果是push,把replace 改成push。