allPoints 里的属性是累加的,个数不确定:
allPoints = {
0:[{ x: 0, y: 0 }],
...,
100:[{ x: 0, y: 0 }],
...
}
这样要如何定义 interface 呢?
allPoints = [
[{ x: 0, y: 0 }],
...
]
换成数组嘞?
allPoints 里的属性是累加的,个数不确定:
allPoints = {
0:[{ x: 0, y: 0 }],
...,
100:[{ x: 0, y: 0 }],
...
}
这样要如何定义 interface 呢?
allPoints = [
[{ x: 0, y: 0 }],
...
]
换成数组嘞?
interface Points {
[key: number]: { x: number; y: number }[];
}
const allPoints:Points = {
0:[{ x: 0, y: 0 }],
1:[{ x: 0, y: 0 }],
}
这样?