localStorage sessionStorage

2020-10-28 10:28:49 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<script type="text/javascript">
		
		//增
		localStorage['李文']="美女";
		
		//localStorage.getItem(key):获取指定key本地存储的值

		//localStorage.setItem(key,value):将value存储到key字段

		//localStorage.removeItem(key):删除指定key本地存储的值
		//localStorage.clear();
		//查询
		alert(localStorage.李文);
		//获取指定key本地存储的值
		alert(localStorage.getItem("李文"));
		//将value存储到key字段
		localStorage.setItem("陈业贵",666);
		localStorage.setItem("李文",999);
		//修改
		localStorage["陈业贵"]=999;
		
		localStorage.removeItem("李文");
		console.log(localStorage);
	</script>
</body>
</html>
代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<script type="text/javascript">
			
		
		sessionStorage.b=666;
		console.log(sessionStorage)
	</script>
</body>
</html>
代码语言:javascript复制
<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title></title> 
</head>
<body>
<script type="text/javascript">
	
	/*console.error('郭然要倒霉了');//错误
	alert(1);*/
	console.warn('高波今天高兴了')//警告
	//console.log(console);




</script>
</body>
</html>

0 人点赞