// 將樹形結(jié)構(gòu)數(shù)組轉(zhuǎn)換成一維數(shù)組
function flattenTreeToArray(list, childrenKey = 'children') {
? let newList = [];
? deepArray(newList, list, childrenKey);
? return newList;
}
function deepArray(newList, list, childrenKey = 'children') {
? list.forEach(item => {
? ? newList.push(item);
? ? if (Array.isArray(item[childrenKey]) && item[childrenKey].length > 0) {
? ? ? deepArray(newList, item[childrenKey], childrenKey);
? ? }
? });
}
// 計算高度震桶,一般用于很簡單的page希停,有表單,table這種
// 計算元素高度
const calculateEleActualHeight = (addList, subtractList) => {
? let total = 0;
? addList.forEach(item => {
? ? let el = document.querySelector(item);
? ? if (el) total += el.clientHeight;
? });
? let subtractTotal = 0;
? subtractList.forEach(item => {
? ? let el = document.querySelector(item);
? ? if (el) subtractTotal += el.clientHeight;
? });
? return total - subtractTotal;
};