1 export function section(): void { 2 const ul = document.getElementById('ul'); 3 const total = 10001; 4 const once = 20; 5 function loop(curTotal: number): void { 6 if (curTotal <= 0) { 7 return; 8 } 9 const pageCount = Math.min(curTotal, once); 10 window.requestAnimationFrame(() => { 11 const fragment = document.createDocumentFragment(); 12 for (let i = 0; i < pageCount; i++) { 13 const li = document.createElement('li'); 14 li.innerText = `${i}`; 15 fragment.appendChild(li); 16 } 17 ul && ul.appendChild(fragment); 18 }); 19 loop(curTotal - pageCount); 20 } 21 loop(total); 22 }