← 教程列表
news

Task 3: localStorage Persistence

📅 2026/6/12 16:30:02⏱ 约 5 分钟阅读👁 8 阅读

Add persistence layer for todos. **Do:** - Create `src/lib/storage.ts` - Implement `loadTodos(): Todo[]` and `saveTodos(todos: Todo[])` - Handle JSON parse errors gracefully (return empty array) - Integrate with store: load on init, save on change - Add tests for load/save/error handling **Verify:** - Tests pass - Manual test: add todo, refresh page, todo persists ---

← 返回教程列表 AI8899 · 内容仅供学习参考