localStorage用法

引用:https://www.cnblogs.com/st-leslie/p/5617130.html

const  STORAGE_KEY = 'todos-vuejs';
export default{
  fetch(){
    return JSON.parse(window.localStorage.getItem(STORAGE_KEY) || '[]');
  },
  save(items){
    window.localStorage.setItem(STORAGE_KEY,JSON.stringify(items));
  }
}

 

posted @ 2018-09-10 17:08  万里冰封  阅读(177)  评论(0编辑  收藏  举报