登录nuxt.js后重定向到先前的URL

我基本上想在用户成功登录后重定向到先前的URL。

我使用先前的网址(例如)重定向到登录页面/login?redirect=/page1/page2

而且我想在用户身份验证时将其重定向回该URL。我在auth-module这里使用https : //auth.nuxtjs.org/

我如何登录用户。

methods: {
    async submit() {
      await this.$auth.loginWith('local', {
        data: this.form
      })
    }
}

我在文档中可以找到的唯一东西是:https : //auth.nuxtjs.org/getting-started/options#redirect

但是,它仅重定向到特定页面而不是查询中的上一页。

关于如何实现这一目标的任何想法?

西里神奇2020/03/26 16:11:04

你可以这样做

  this.$router.back()

然后返回到最后一条路线。

程序导航| Vue路由器 https://router.vuejs.org/guide/essentials/navigation.html

谢谢。