当前位置:网站首页>sessionStorage of BOM series
sessionStorage of BOM series
2022-08-03 13:16:00 【old__L】
目录
1、属性
1.1、length
1.1.1、概述
length 是 sessionStorage 接口的只读属性,返回一个整数,表示存储在 sessionStorage data items in the object(data items)数量.
1.1.2、语法
var aLength = sessionStorage.length;
1.1.3、返回值
一个整数
2、方法
2.1、存储数据
2.1.1、概述
sessionStorage 接口的 setItem() 方法,Accepts a key and value as parameters,will add the key name to the given sessionStorage 对象中,If the key name already exists,则更新其对应的值.
2.1.2、语法
sessionStorage.setItem(keyName, keyValue);
2.1.3、参数
- keyName
一个 DOMString,Indicates the key name to be created or updated.
- keyValue
一个 DOMString,Represents the value corresponding to the key name to be created or updated.
2.1.4、返回值
undefined
2.1.5、异常
in the case of a full storage,调用 setItem() 可能会抛出异常.Developers should always catch setItem() 可能抛出的异常.
2.2、获取数据
2.2.1、概述
getItem() 作为 sessionStorage 接口的方法,accepts a key name(key name)作为参数,and returns the value corresponding to the key name(key’s value).
2.2.2、语法
var aValue = sessionStorage.getItem(keyName);
2.2.3、参数
- keyName
One containing the key name DOMString.
2.2.4、返回值
一个 DOMString,键名对应的值.If the key name does not exist in the store,则返回 null.
2.3、删除数据
2.3.1、概述
sessionStorage 接口的 removeItem() 方法,accepts a key name作为参数,会从给定的 sessionStorage Delete the key name from the object(如果存在). If there is no item matching the given key name,then this method will do nothing.
2.3.2、语法
sessionStorage.removeItem(keyName);
2.3.3、参数
- keyName
一个 DOMString,i.e. the name of the key you want to remove.
2.3.4、返回值
无
2.4、清空数据(所有都清除掉)
2.4.1、概述
clear() 是 sessionStorage 接口的一个方法,Call it to clear all key values in the storage object.
2.4.2、语法
sessionStorage.clear();
2.4.3、参数
无
2.4.4、返回值
无
2.5、键
2.5.1、概述
key() 作为 sessionStorage 接口的方法,接受一个数值 n 作为参数,Returns the stored object No n 个数据项的键名.The order in which keys are stored is defined by the user agent,So try not to rely on this method as much as possible.
2.5.2、语法
var aKeyName = sessionStorage.key(key);
2.5.3、参数
- key
一个整数,Indicates the key name index to get.
2.5.4、返回值
One containing the key name DOMString.
后记
如果你感觉文章不咋地
//(ㄒoㄒ)//
,就在评论处留言,作者继续改进;o_O???
如果你觉得该文章有一点点用处,可以给作者点个赞;\\*^o^*//
如果你想要和作者一起进步,可以微信扫描二维码,关注前端老L;~~~///(^v^)\\\~~~
谢谢各位读者们啦(^_^)∠※
!!!
边栏推荐
猜你喜欢
有趣的opencv-记录图片二值化和相似度实现
Sogou news-数据集
An动画基础之散件动画原理与形状提示点
The common problems in the futures account summary
[Practical skills] APP video tutorial for updating APP in CANFD, I2C, SPI and serial port mode of single-chip bootloader (2022-08-01)
Yahoo! Answers-数据集
leetcode16最接近的三数之和 (排序+ 双指针)
Classes and objects (upper)
PyTorch框架训练线性回归模型(CPU与GPU环境)
[微服务]多级缓存
随机推荐
How does Filebeat maintain file state?
Notepad++ 安装jsonview插件
Golang 通道 channel
An工具介绍之钢笔工具、铅笔工具与画笔工具
SQL分页查询_Sql根据某个字段分页
软件测试面试(四)
Classes and Objects (lower middle)
Golang 字符串
d写二进制
Graphic animation and button animation of an animation basic component
Tinymce plugins [Tinymce扩展插件集合]
基于php校园医院门诊管理系统获取(php毕业设计)
Golang 结构体&方法
IronOS, an open source system for portable soldering irons, supports a variety of portable DC, QC, PD powered soldering irons, and supports all standard functions of smart soldering irons
The Yangtze river commercial Banks to the interview
Sogou news - dataset
【OpenCV】 书本视图矫正 + 广告屏幕切换 透视变换图像处理
[数据仓库]分层概念,ODS,DM,DWD,DWS,DIM的概念「建议收藏」
JS get browser type
Golang 接口 interface