角度锁定器localstorage在刷新后被删除

时间:2017-06-09 11:30:41

标签: javascript angularjs html5 local-storage

当我刷新应用程序时,本地存储会自动删除。 这里使用了angular-locker,即使我没有在项目中的任何地方使用locker.empty()。 enter image description here

2 个答案:

答案 0 :(得分:1)

浏览器永远不会重置您的本地存储空间。它必须隐藏数据或者代码中必须有一些脚本正在执行此操作。

  

与localStorage.clear();

一样

尝试关闭并打开开发人员工具选项卡(f12 / ctrl + shift + i),当我刷新页面时,我的浏览器会隐藏localstorage,但当我关闭并重新打开开发人员工具选项卡时,我能够再次看到本地存储数据。

答案 1 :(得分:0)

I don't think your local storage is removed , it is just invisible.. just try to print your data stored in local storage.

console.log(localStorage.getItem("your key"));

and you will get result.

it is a bug , if you want to check then just try to clear the storage and keep the Application tag open in developer option, you will see it will be there and once you reload it will disappear but data will be there..