简体   繁体   English

Nuxt:有没有办法持久化 $auth.user?

[英]Nuxt: Is there a way to persist $auth.user?

In my Nuxt application, when i log in, i set my user info at $auth.setUser(user) function and it stores it globally as it is supposed to, but when i refresh the page, my $auth.user object becomes a Observer object and not my user info.在我的 Nuxt 应用程序中,当我登录时,我将我的用户信息设置为 $auth.setUser(user) function 并按预期将其存储在全球范围内,但是当我刷新页面时,我的 $auth.user object 变成了观察员 object 而不是我的用户信息。 Is there a way to persist $auth.user so that when i refresh the page i still have my user info?有没有办法保留 $auth.user 以便当我刷新页面时我仍然有我的用户信息? I'm going to use static pages so it will be needed when my user has no connection with the server.我将使用 static 页面,因此当我的用户与服务器没有连接时将需要它。

My login request is as follow:我的登录请求如下:

this.$auth.loginWith('extScheme', { data: {user: this.user} }).then( ret=>{
  this.$auth.setUser(ret.data)
})

Thanks谢谢

Found out:发现:

This plugin( vuex-persist ) will persist any vuex store to local storage, $auth stuff included.这个插件( vuex-persist )将把任何 vuex 存储保存到本地存储,包括 $auth 东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM