This error occurs when the Vue router tries to navigate to a location that is already the current location. This is not allowed by default to prevent unnecessary re-rendering of the component tree.

To resolve this issue, you can either:

  1. Avoid navigating to the current location in your code.
  2. Use a catch block to handle the 'NavigationDuplicated' error and prevent it from being thrown. You can do this by adding a catch block to your router.push() or router.replace() methods.

For example:

router.push('/cs?a=244').catch(err => {
  if (err.name !== 'NavigationDuplicated') {
    throw err
  }
})

This will catch the 'NavigationDuplicated' error and prevent it from being thrown, while allowing other errors to be thrown.

Vue Router NavigationDuplicated Error: Causes and Solutions

原文地址: https://www.cveoy.top/t/topic/mutC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录