This commit is contained in:
rou
2026-03-26 21:45:32 +08:00
parent 7c0cbe1320
commit 2a65ba8c6a
7 changed files with 169 additions and 59 deletions

View File

@@ -49,31 +49,49 @@ new Vue({
// 任务:
// 1. 先按 statusFilter 过滤
// 2. 再按 keyword 过滤标题
return this.courses;
let value = this.keyword.trim().toUpperCase()
let a
if (this.statusFilter === "all") {
a = this.courses.filter(item => item.title.toUpperCase().includes(value))
} else if (this.statusFilter === "done") {
const b = this.courses.filter(item => item.finished === true)
a = b.filter(item => item.title.toUpperCase().includes(value))
} else if (this.statusFilter === "doing") {
const b = this.courses.filter(item => item.finished === false)
a = b.filter(item => item.title.toUpperCase().includes(value))
}
return a
},
totalCount() {
return this.courses.length;
},
finishedCount() {
// 任务:返回已完成课程数量
return 0;
const b = this.courses.filter(item => item.finished === true)
return b.length
},
visibleCount() {
// 任务:返回当前筛选后的数量
return 0;
const a = this.filteredCourses
return a.length;
},
},
watch: {
keyword(newValue) {
// 任务:在控制台输出关键字变化
console.log(`关键词:${newValue}`);
},
},
methods: {
toggleCourse(courseId) {
// 任务:根据 courseId 切换 finished
const a = this.courses.find(item => item.id === courseId)
a.finished = !a.finished
},
focusSearch() {
// 任务:通过 ref 聚焦输入框
this.$refs.searchInput.focus()
},
},
});