我正在努力编辑 ToDo 应用程序上的任务并更新 localstorage 对象中的更改。我试过 contenteditable 来编辑 UI 上的文本。但是,我无法更新对 localstorage 数组的更改。这是我正在使用的代码。任何建议将不胜感激!
// Edit task
const eidtTask = (e) => {
// Array of objects of tasks
const tasks = JSON.parse(localStorage.getItem('tasks'));
if(e.target.classList.contains('edit')) {
// When I click edit button I want to edit the task and update the value on localstorage array as well
}
localStorage.setItem('tasks', JSON.stringify(tasks));
};
撒科打诨
相关分类