有的時候,前端向后端發送請求,json體積太大可以用數據切片分批發送請求
// 原數組 const todolists = this.todolist.tableList // 切片的待保存數組 const newArr = [] // 切片數量 const section = 15 // 進行切片 for (var i = 0; i < todolists.length; i += section) { newArr.push(todolists.slice(i, i + section)) } // 循環切片次數 for (let j = 0; j < newArr.length; j++) { console.log(newArr[j]) // 發送請求記得使用await 同步提交請求 }