1.localStorage
用于长久保存整个网站的数据,保存的数据没有过期时间,直到手动去除
localStorage 对象存储的数据没有时间限制。第二天、第二周或下一年之后,数据依然可用。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body></body>
<script>
// 判断浏览器是否支持缓存
console.log(typeof Storage === 'undefined');
localStorage.name = '张三';
console.log(localStorage.name);
</script>
</html>
2.localStorage_API
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" /