答案 0 :(得分:2)
这是我认为可以使用的一种解决方案:
<div id="container" style={{display: 'flex', flexDirection: 'row', flexWrap: 'wrap'}}>
{arrayList.map((listItem, index) => {
const cardinalIndex = index + 1;
const item = !(cardinalIndex % 10) ? (
<React.Fragment>
<div id="item" style={{flex: '1 1 25%'}}>
{listItem}
</div>
<img style={{flex: '1 1 100%'}} src="" />
</React.Fragment>
) : (
<div id="item" style={{flex: '1 1 25%'}}>
{listItem}
</div>
);
return item;
})}
答案 1 :(得分:1)
//itemList is your array
let temp = [];
while (itemList.length > 0) {
temp.push(itemList.splice(0, 10));
}
let res = [];
temp.forEach(e => {
res = [...res, ...e, 'new item here'];
});
//res is your output array with inserted elements