错误:
1. script.js:153 Uncaught TypeError: Cannot set property 'display' of
undefined
at script.js:153
at NodeList.forEach (<anonymous>)
at HTMLSelectElement.filterTodo (script.js:150)
代码:
enter code here function filterTodo(e) {
let todos = todoList.childNodes;
todos.forEach(function(todo) {
switch (e.target.value) {
case "all":
todo.style.display = "flex";
break;
case "completed":
if (todo.classList.contains("completed")) {
todo.style.display = "flex";
} else {
todo.style.display = "none";
}
break;
case "uncompleted":
if (!todo.classList.contains("completed")) {
todo.style.display = "flex";
} else {
todo.style.display = "none";
}
}
});
}