// 本地存储
setStorage(name, data){
let dataType = typeof data;
// json对象
if(dataType === 'object'){
window.localStorage.setItem(name, JSON.stringify(data));
}
// 基础类型
else if(['number','string','boolean'].indexOf(dataType) >= 0){
window.localStorage.setItem(name, data);
}
// 其他不支持的类型
else{
alert('该类型不能用于本地存储');
}
}
// 取出本地存储内容
getStorage(name){
let data = window.localStorage.getItem(name);
if(data){
return JSON.parse(data);
}
else{
return '';
}
}
// 删除本地存储
removeStorage(name){
window.localStorage.removeItem(name);
}

最新文章

  1. eclispe+axis2+webservice入门
  2. input 放大镜
  3. javascript--Function
  4. C语言中scanf()的用法!
  5. MySQL对于数据库应该如何如何配置安全问题了
  6. 【转】使用C#实现ADSL自动拨号
  7. SQLite数据库简介(转)
  8. git ssh认证
  9. Docker私有仓库Registry 搭建
  10. CF908D Arbitrary Arrangement
  11. Python菜鸟快乐游戏编程_pygame(3)
  12. PyCharm下载及使用
  13. Linux 环境 Maven 安装&仓源配置
  14. JAVA常用工具类汇总
  15. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
  16. applyColorMap()研究(如果我对现有的colormap不满意,那么如何具体来做)
  17. 分割(partition,stable_partition)
  18. SVN previous operation has not finished
  19. js中的深层复制
  20. Cookie、Session、Token

热门文章

  1. Delphi遍历进程-Win32API
  2. Servlet与Struts的区别
  3. 在当前目录打开DOS命令行窗口
  4. pandas一些基本操作(DataFram和Series)_2
  5. quartz 定时任务配置文件信息
  6. 如何正确使用 Flink Connector?
  7. ES6 class继承
  8. PAT甲级——A1023 Have Fun with Numbers
  9. Google 和 微软,就不是一个重量级的
  10. 跟我一起了解koa(二)