标签:name ring get 封装 catch tor value 持久 cat
export const setItem = (name, value) => { if (typeof value === ‘object‘) { value = JSON.stringify(value) } window.localStorage.setItem(name, value) } export const getItem = name => { const data = window.localStorage.getItem(name) try { return JSON.parse(data) } catch (err) { return data } } export const removeItem = name => { window.localStorage.removeItem(name) }
vue项目常用之三:window.localStorage持久化存储数据封装
标签:name ring get 封装 catch tor value 持久 cat
原文地址:https://www.cnblogs.com/wtsx-2019/p/12546076.html