简单封装localstore

export default {
    getItem:(key)=>{
        let value
        try{
            value = localStorage.getItem(key)
        }catch(err){
            console.log(err.message);
        }finally{
            return value
        }
    },
    setItem:(key,value)=>{
        try{
            localStorage.setItem(key,value)
        }catch(err){
            console.log(err.message);
        }
    }
}

 

posted @ 2022-04-07 08:45  古德拉克  阅读(67)  评论(0编辑  收藏  举报