19、localStorage.getItem得到的是[object Object] 的解决方案
2024-09-06 00:39:10
实现本地存储,避免刷新页面数据丢失:
localStorage.setItem 只能存储字符串,
所以在储存的时候先将对象转换为字符串
localStorage.setItem("localKey", JSON.stringify(this.cartGroup))
然后再将字符串转换为对象
方法1: JSON.parse(localStorage.getItem("localKey") 方法2: eval("("+localStorage.getItem("localKey")+")")
最新文章
- Python标准模块--linecache
- linux 服务的操作
- [NOIP2012] 提高组 洛谷P1083 借教室
- java使用poi读取ppt文件和poi读取excel、word示例
- select_tag in rails about selected not change and onchange()
- XML工程配置文件的读写
- NUnit Test Adapter----单元测试需要安装这个插件
- 直面Javascript面试题算法思路
- 【软件工程-Teamwork 3】团队角色分配和团队贡献分分配规则
- getopt使用例子
- hackerrank:Almost sorted interval
- 程序猿学英语—In July the English learning summary
- 快速掌握LODOP打印使用方法
- 【Android Developers Training】 107. 认知用户当前的行为
- 浮动和BFC的学习整理转述
- idea 配置 maven 项目
- SpringMCV跨域
- Email实例
- (转)Redis(四)哨兵_sentinel
- CXF wsdl2java (转载)
热门文章
- git常用命令(测试必备)
- 重新学习Spring注解——ICO
- no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]]
- RabbitMQ六种队列模式-简单队列模式
- postfix发邮件失败,日志和postqueue -p提示No route to host
- redis使用摘要
- 网络协议 5 - ICMP 与 Ping
- VueCli3新特性
- 一些树上dp的复杂度证明
- nginx配置神器