本地存储封装

storage

let storage={
    get (key) {
        return JSON.parse(localStorage.getItem(key))
    },
    set (key, value) {
        localStorage.setItem(key, JSON.stringify(value))
    },
    clear () {
        localStorage.clear()
    },
    removeItem (key) {
        localStorage.removeItem(key)
    }
}

 

 

cookie

 

posted @ 2018-09-10 15:51  丁少华  阅读(306)  评论(0编辑  收藏  举报