vue-save-state
Version:
A Vue mixin to save the state of a component to local storage
21 lines (17 loc) • 487 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.saveState = saveState;
exports.getSavedState = getSavedState;
exports.clearSavedState = clearSavedState;
function saveState(key, data) {
localStorage.setItem(key, JSON.stringify(data));
}
function getSavedState(key) {
var savedState = localStorage.getItem(key);
return savedState ? JSON.parse(savedState) : null;
}
function clearSavedState(key) {
localStorage.removeItem(key);
}
;