vue后退判断是否有历史记录,有就返回上一级,否则返回指定路由

Vue.prototype.back = function (route) {
  if (window.history.length > 1) {
    this.$router.back();
  } else {
    this.$router.push(route);
  }
}
原文地址:https://www.cnblogs.com/peter-web/p/13044614.html