我正在努力編輯 ToDo 應用程序上的任務并更新 localstorage 對象中的更改。我試過 contenteditable 來編輯 UI 上的文本。但是,我無法更新對 localstorage 數組的更改。這是我正在使用的代碼。任何建議將不勝感激!// Edit taskconst 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));};
如何在 UI 上編輯文本并使用 Javascript 更新 localStorage 中的更改
鴻蒙傳說
2022-12-09 19:52:09
