2
0

store.js 466 B

1234567891011121314151617181920212223
  1. /*jshint unused:false */
  2. (function (exports) {
  3. 'use strict';
  4. var STORAGE_KEY = 'todos-vuejs-2.0';
  5. exports.todoStorage = {
  6. fetch: function () {
  7. var todos = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
  8. todos.forEach(function (todo, index) {
  9. todo.id = index
  10. });
  11. exports.todoStorage.uid = todos.length;
  12. return todos;
  13. },
  14. save: function (todos) {
  15. localStorage.setItem(STORAGE_KEY, JSON.stringify(todos));
  16. }
  17. };
  18. })(window);