前言,原数据是二维数组,含树形数据效果
效果:
只有一级的情况:
原数据:
代码:
二维数组中有树形结构的情况:
数据:
效果图:
代码:
:prop="`caseList.${ItemIndex}.${findTableIndex(item,scope.row.unique)}.caseFileName`" :rules="rules.caseFileName"
// 校验表单的方法
findTableIndex(tree, unique, path = '') {
for (let i = 0; i < tree.length; i++) {
const node = tree[i]
if (node.unique === unique) {
return path + i
}
if (node.children && node.children.length > 0) {
const childPath = `${path}${i}.children.`
const result = this.findTableIndex(node.children, unique, childPath)
if (result !== null) {
return result
}
}
}
return null
},