useEffect(() => {
const numbers = getPatternedIndexes(data?.length);
// numbers.forEach((val) => {
// data[val].flag = true;
// });
console.log(numbers);
}, []);
const getPatternedIndexes = (limit) => {
const result = [];
let i = 0;
while (i <= limit - 1) {
result.push(i);
if ((result.length - 1) % 2 === 0) {
i += 3;
} else {
i += 1;
}
}
return result;
};
获取数组中下标为[0, 3, 4, 7, 8, 11, 12]的数据(瀑布流的数据)
于 2024-08-25 21:52:29 首次发布