UNPKG

vue-save-state

Version:

A Vue mixin to save the state of a component to local storage

14 lines (10 loc) 316 B
export function saveState(key, data) { localStorage.setItem(key, JSON.stringify(data)); } export function getSavedState(key) { const savedState = localStorage.getItem(key); return savedState ? JSON.parse(savedState) : null; } export function clearSavedState(key) { localStorage.removeItem(key); }