💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
>[info] 遍历children形式数据 ~~~ /** * 遍历children形式数据 * @param data 需要遍历的数组 * @param callback 回调 * @param childKey children字段名 */ export function eachTreeData(data, callback, childKey = 'children') { if (!data || !data.length) { return; } data.forEach((d) => { if (callback(d) !== false && d[childKey]) { eachTreeData(d[childKey], callback, childKey); } }); } ~~~ ~~~ computed: { // 权限树选中数据 checked() { let checked = []; this.$util.eachTreeData(this.authData, d => { if (d.checked && (!d.children || !d.children.length)) { checked.push(d.id); } }); return checked; } }, ~~~