📌  相关文章
📜  将数据存储在 localstorage javascript 代码示例中

📅  最后修改于: 2022-03-11 15:01:17.332000             🧑  作者: Mango

代码示例5
export const setToLS = (key, value) => {
  window.localStorage.setItem(key, JSON.stringify(value));
}

export const getFromLS = key => {
  const value = window.localStorage.getItem(key);

  if (value) {
    return JSON.parse(value);
  }
}