vuex-persistedstate

  1. 核心原理:在本地存储中存入所有的vuex数据,页面刷新时到缓存中取数据,放到vuex中
  2. 下载:$ npm install vuex-persistedstate -s
  3. 在store中引入插件

vuex-persistedstate默认使用localstorage储存,若想使用sessionstorage,可采用以下配置

  • 若想使用cookie,可采用以下配置
  • 下载:$ npm install js-cookie -s

secure-ls

  • 加密storage
  • 当我们在vuex中保存了用户信息,虽然使用起来方便了很多,但是为了解决vuex刷新页面数据丢失的问题,使用了vuex-persistedstate插件,vuex-persistedstate是没有加密的,用户的信息就暴露在缓存中,
  • 非常的不安全,所以需要配合secure-ls来加密storage
  • 下载: $ npm install secure-ls -s

【注】vuex-persist(不兼容ie) vuex-persistedstate

到此这篇关于vuex强刷数据丢失的文章就介绍到这了,更多相关vuex数据丢失内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!