Vue Router - JANGCHICKEN/Study GitHub Wiki

NavigationDuplicated silent 시키는 법

Use this code in router.js file.

// in JS
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
}

// in TS
const originalPush = Router.prototype.push;
Router.prototype.push = async function (location: RawLocation) {
  let route: Route;
  try {
    route = await originalPush.call<Router, [RawLocation], Promise<Route>>(this, location);
  } catch (err) {
    if (err.name !== 'NavigationDuplicated') {
      throw err;
    }
  }

  return route!;
}
⚠️ **GitHub.com Fallback** ⚠️