<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                >[info] pid形式數據轉children形式 ~~~ /** * pid形式數據轉children形式 * @param data 需要轉換的數組 * @param idKey id字段名 * @param pidKey pid字段名 * @param childKey 生成的children字段名 * @param pid 頂級的pid * @param addPIds 是否添加所有父級id的字段 * @param parentsKey 所有父級id的字段名稱,默認parentIds * @param parentIds 所有父級id * @returns {[]} */ export function toTreeData(data, idKey, pidKey, childKey, pid, addPIds, parentsKey, parentIds) { if (typeof data === 'object' && !Array.isArray(data)) { idKey = data.idKey; pidKey = data.pidKey; childKey = data.childKey; pid = data.pid; addPIds = data.addPIds; parentsKey = data.parentsKey; parentIds = data.parentIds; data = data.data; } if (!idKey) { idKey = 'id'; } if (!pidKey) { pidKey = 'pid'; } if (!childKey) { childKey = 'children'; } if (typeof pid === 'undefined') { pid = []; data.forEach((d) => { let flag = true; for (let i = 0; i < data.length; i++) { if (d[pidKey] == data[i][idKey]) { flag = false; break; } } if (flag) { pid.push(d[pidKey]); } }); } let result = []; data.forEach((d) => { if (d[idKey] == d[pidKey]) { console.error('data error: ', d) return; } if (Array.isArray(pid) ? (pid.indexOf(d[pidKey]) !== -1) : (d[pidKey] == pid)) { let children = toTreeData({ data: data, idKey: idKey, pidKey: pidKey, childKey: childKey, pid: d[idKey], addPIds: addPIds, parentsKey: parentsKey, parentIds: (parentIds || []).concat([d[idKey]]) }); if (children.length > 0) { d[childKey] = children; } if (addPIds) { d[parentsKey || 'parentIds'] = parentIds || []; } result.push(d); } }); return result; } ~~~ ~~~ // 樹結構 this.cateList = toTreeData(res.data.data, 'id', 'pid'); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看