首页 > 其他 > 详细

封装locaostorage

时间:2018-07-14 13:48:13      阅读:185      评论:0      收藏:0      [点我收藏+]
 1 const ls = localStorage
 2 
 3 export default {
 4   setItem(name, value) {
 5     ls.setItem(name, JSON.stringify(value))
 6   },
 7   getItem(name) {
 8     try {
 9       return JSON.parse(ls.getItem(name))
10     } catch (e) {
11       return null
12     }
13   },
14   removeItem(name) {
15     ls.removeItem(name)
16   }
17 }

 

封装locaostorage

原文:https://www.cnblogs.com/yangguoe/p/9309358.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!