代码优化 if thisallChecked thismaterialAudioListforEachitem = itemchecked = true else thischeckedCounts = 0 thisallChecked = false thismaterial
可以使用数组的map方法来简化代码:
this.materialAudioList = this.materialAudioList.map(item => { item.checked = !this.allChecked; return item; }); this.checkedCounts = this.allChecked ? this.materialAudioList.length : 0; this.allChecked = !this.allChecked;
原文地址: http://www.cveoy.top/t/topic/bArW 著作权归作者所有。请勿转载和采集!