1.计算属性,定义在computed中的数据属性,当相关数据发生变化时,计算属性的数据自动实现更新操作。
computed: {
selectionFile() {
var selection = [];
for (var i = 0; i < this.fileList.length; i++) {
if (this.fileList[i].checked == true) {
selection.push(this.fileList[i]);
} else {
console.log(this.fileList[i].checked);
}
}
return selection;
},
},
注:数据返回后存储在属性名称中,且该属性不能在data中再次定义,否则会有冲突。