let ddd = [
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"x2": 3,
"y": 2,
"x1": 2,
"x0": 1
},
{
"key": "kong"
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"key": "kong"
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"x2": 3,
"y": 2,
"x1": 2,
"x0": 1
},
{
"key": "kong"
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"key": "kong"
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"x2": 3,
"y": 2,
"x1": 2,
"x0": 1
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"key": "kong"
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"key": "kong"
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"key": "kong"
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"key": "kong"
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"key": "kong"
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"key": "kong"
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"key": "kong"
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"key": "kong"
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 3,
"x1": 2
},
{
"key": "kong"
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 3
},
{
"key": "kong"
}
],
[
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"key": "kong"
},
{
"x0": 1,
"y": 4,
"x2": 3,
"x1": 2
},
{
"x0": 1,
"y": 5,
"x1": 2
},
{
"y": 6,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 7,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 8,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 9,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 10,
"x1": 2,
"x2": 3
},
{
"x0": 1,
"y": 11,
"x1": 2
},
{
"x1": 2,
"y": 12,
"x2": 8888
},
{
"key": "kong2"
}
]
]
function split2DArray(arr, num) {
let newArr = [];
for (let i = 0; i < arr.length; i += num) {
newArr.push(arr.slice(i, i + num));
}
return newArr;
}
//存数据前先删除以前缓存
for (let i = 0; i < 20; i ++) {
let abc = localStorage.getItem('keySpl' + i)
if (abc){
localStorage.removeItem('keySpl' + i)
}
}
// 数据截取后存入缓存
let sli = split2DArray(ddd, 6)
let leg = Math.ceil(ddd.length/6)
sli.forEach((item, index) => {
localStorage.setItem('keySpl' + index, JSON.stringify(item))
})
// 复原缓存中被截取保存的数据
let plm = []
for (let i = 0; i < leg; i++) {
plm = [...plm, ...JSON.parse(localStorage.getItem('keySpl' + i))]
}
console.log(plm, 8)