其他分享
首页 > 其他分享> > 简单封装localstore

简单封装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);
        }
    }
}

 

标签:封装,localstore,err,value,setItem,localStorage,key,简单,console
来源: https://www.cnblogs.com/gdluck/p/16110692.html