var arr= [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]; var num = 1; var initnum = 0; for(var i=0;i<arr.length;i++){ if(initnum<num){ arr[i].val=num; initnum++ }else{ initnum = 0; initnum++; num++; arr[i].val=num; } } console.log(arr)
简单的逻辑
最新推荐文章于 2024-09-08 21:29:56 发布