本文介绍了sessionStorage在localStorage中的PhoneGap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个PhoneGap应用程序,并使用sessionStorage而不是localStorage,因为我们面临一些localStorage的问题。

I am currently developing a PhoneGap application and am using sessionStorage rather than localStorage because we are facing some problems with localStorage.

使用sessionStorage over localStorage有任何缺点?

Are there any downsides to using sessionStorage over localStorage?

推荐答案

sessionStorage在每次关闭应用程序时都会被擦除。除此之外没有区别。

sessionStorage gets erased every time you close the application. Other than that there is no difference.

这里是使用示例:

var keyName = window.sessionStorage.key(0); //Get key name
window.sessionStorage.setItem("key", "value"); //Set item
var value = window.sessionStorage.getItem("key");// Get item
window.sessionStorage.removeItem("key"); //Remove Item 
window.sessionStorage.clear();//Clear storage

这篇关于sessionStorage在localStorage中的PhoneGap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 09:19