function setIndex(data) { let queue = [...data]; let loop = 0; while (queue.length > 0) { loop++; for (const [i, child] of [...queue].entries()) { queue.shift(); if (loop == 1) { child.customIndex = ${i + 1}; child.currentIndex = i; child.path = i; } if (child.children && child.children.length > 0) { child.dataType = 1; for (const [ci, cChild] of child.children.entries()) { cChild.currentIndex = ci; cChild.customIndex = ${child.customIndex}.${ci + 1}; cChild.path = ${child.path}.children.${ci}; } queue.push(...child.children); } else { child.dataType = 2; } } }

function setIndex data let queue = data; let loop = 0; while queuelength 0 loop++ queueforEachchild i = queueshift if loop == 1 childcu

原文地址: http://www.cveoy.top/t/topic/hmqy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录