Vue Avoided redundant navigation to current location: "/login".

=================================

报错解释:
这个错误是在使用Vue.js框架时,发生的一个警告,表示尝试进行一个冗余的导航到当前位置(即“/login”路径)。这通常发生在Vue Router中,当你尝试通过编程方式导航到当前正在显示的路径时。

解决方法:
    检查你的路由跳转代码,确保不会不小心导航到当前位置。例如,避免在用户已经在"/login"页面时调用this.$router.push('/login')。
    可以使用this.$router.push之前,先判断当前路径是否已经是目标路径,只有在不同路径时才进行跳转。
    使用replace替换而不是push,这样可以避免在历史记录中创建新的记录,从而避免可能产生的冗余导航问题。

示例代码:

// 假设当前路径是/current-path
if (this.$route.path !== '/login') {
  this.$router.replace('/login');
}=================================
if (this.$route.path !== '/login') {
  this.$router.push('/login')
}=================================