使用计算属性中使用高阶函数会更简洁些,但对于新手不友好,老师还是照顾到了大部分同学。感谢老师
computed:{ listData(){ let list = JSON.parse(JSON.stringify(this.list)) let newList = [] if(this.activeIndex == 0){ newList = list } if(this.activeIndex == 1){ newList = list.filter(item => item.checked == false) } if(this.activeIndex == 2){ newList = list.filter(item => item.checked == true) } return newList } }