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 } }
computed:{
listData(){
if(this.activeIndex === 0){
return this.list
}
if(this.activeIndex === 1){
return this.list.filter(i=>{
return i.checked != true
})
}
if(this.activeIndex === 2){
return this.list.filter(i=>{
return i.checked == true
})
}
}
},
把计算属性处理出函数,更好