使用計算屬性中使用高階函數(shù)會更簡潔些,但對于新手不友好,老師還是照顧到了大部分同學(xué)。感謝老師
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
????}?
}
2022-05-21
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
})
}
}
},
? ? ? ? ? ?2022-03-17
把計算屬性處理出函數(shù),更好