Vue.js 如何在vuex中使用nuxt-i18n包中的LocalRoute

Vue.js 如何在vuex中使用nuxt-i18n包中的LocalRoute,vue.js,nuxt.js,vuex,vue-i18n,nuxt-i18n,Vue.js,Nuxt.js,Vuex,Vue I18n,Nuxt I18n,我正在尝试从中使用localRoute方法 this.$router.push(this.localerout({name:“home”})) 我尝试过这种方法,但不起作用,正确的方法是什么?在vuex中,this.localRoute或this.localPath未定义,因为“this”不在上下文中 有效的方法是将整个localPath对象传递到动作中 因此,在您的方法中,您可以这样做: test(){ let route = this.localePath({ name: 'fo

我正在尝试从中使用localRoute方法

this.$router.push(this.localerout({name:“home”}))


我尝试过这种方法,但不起作用,正确的方法是什么?

在vuex中,this.localRoute或this.localPath未定义,因为“this”不在上下文中

有效的方法是将整个localPath对象传递到动作中

因此,在您的方法中,您可以这样做:

test(){
      let route = this.localePath({ name: 'forgotPassword' })
      this.$store.dispatch('storeTest', route)
    },
然后在动作中,您可以执行以下操作:

  storeTest({ commit }, route){

     this.app.router.push(route) //this works
     $nuxt._router.push(route) //this works as well
  },

同样,如果其他选项不起作用,您可以将整个路由器传递到操作中。然后您可以执行以下操作:
router.push(route)

您是否收到任何错误/异常?未定义的localerout