Skip to content

当我刷新浏览器地址的时候,state里面的内容被清空了。 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shinygang opened this issue Jan 26, 2016 · 7 comments
Closed

Comments

@shinygang
Copy link

hi all,
我们项目中最近准备引用vuex,但是发现一个问题:当我刷新浏览器地址的时候,state里面保存的数据被清空了。请指导一下怎么解决。

@jianfei
Copy link

jianfei commented Jan 26, 2016

刷新相当于App重载了 数据当然会清空 你可以把数据存在cookie, session或者localstorage

@shinygang
Copy link
Author

@jianfei 如果这样子的话,我感觉vuex意义不大了啊。

@yyx990803
Copy link
Member

@shinygang 你是不是理解错 vuex 的意义了...

@shinygang
Copy link
Author

@yyx990803 我理解的是用vuex做全局状态管理,比如登录后的一些用户信息全局缓存,不用在组件的props上传了。我想用他来替代localStorage之类的本地缓存。

@yyx990803
Copy link
Member

状态管理是为了可维护性和可扩展性,和本地缓存没有任何关系。但是你可以在 middleware 中将状态存入 localStorage。
On Mon, Jan 25, 2016 at 10:28 PM Ryan Wang [email protected] wrote:

@shinygang https://github.com/shinygang 那你想多了。。。


Reply to this email directly or view it on GitHub
#47 (comment).

@Niofh
Copy link

Niofh commented Dec 4, 2016

楼主,vuex刷新给清楚了是什么回事!!

@YiBanCangBai
Copy link

@yyx990803 有道理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants