这个怎么更强有效的刷新fileLists 的值 handleDownloadFileRemove file consolelogRemov-filefile consolelogRemov-file-fileIdfilefileId const index1 = thisfileListsindexOffile const newFileList = thisfileListsslice new
要更强有效地刷新fileLists的值,可以使用以下代码:
handleDownloadFileRemove(file) {
console.log("Remov-file", file);
console.log("Remov-file-fileId", file.fileId);
const index1 = this.fileLists.findIndex((item) => item.fileId === file.fileId);
if (index1 !== -1) {
this.fileLists.splice(index1, 1);
this.$set(this.mdl, 'qaFileId', JSON.stringify(this.fileLists));
}
}
这个函数首先使用findIndex方法查找要删除的文件对象在fileLists数组中的索引。如果找到了对应的索引,就使用splice方法将其从数组中删除。然后使用$set方法更新mdl对象中的qaFileId属性,将删除后的fileLists数组转换为字符串并赋值给qaFileId。这样就能更强有效地刷新fileLists的值
原文地址: https://www.cveoy.top/t/topic/hXFK 著作权归作者所有。请勿转载和采集!