vue2
This commit is contained in:
@@ -52,15 +52,23 @@ new Vue({
|
||||
computed: {
|
||||
filteredCourses() {
|
||||
// 任务:根据 keyword 过滤课程列表
|
||||
return this.courses;
|
||||
let value = this.keyword.trim().toUpperCase()
|
||||
return this.courses.filter(item => item.title.toUpperCase().includes(value))
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
toggleCourse(courseId) {
|
||||
// 任务:根据 courseId 切换 finished
|
||||
const a = this.courses.find(item => {
|
||||
if (item.id === courseId) {
|
||||
item.finished = !item.finished
|
||||
}
|
||||
return;
|
||||
})
|
||||
},
|
||||
focusInput() {
|
||||
// 任务:通过 ref 聚焦输入框
|
||||
this.$refs.keywordInput.focus()
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user