ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[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; } }, ~~~