我正在关注 vis 中的动态数据集示例,当我尝试设置边缘时遇到打字错误。
我只有一个边缘数组,看起来像:
edgesArray = [
{ from: 1, to: 3 },
{ from: 1, to: 2 },
{ from: 2, to: 4 },
{ from: 3, to: 5 },
]
我将数据设置为
let data = {
nodes: new vis.DataSet(nodesArray),
edges: new vis.DataSet(edgesArray)
}
我得到的错误在边缘。
No overload matches this call.
Overload 1 of 2, '(options?: DataSetInitialOptions<"id">): DataSet<Partial<Record<"id", string | number>>, "id">', gave the following error.
Type '{ from: number; to: number; } []' has no properties in common with type 'DataSetInitialOptions<"id">'.
Overload 2 of 2, '(data: Partial<Record<"id", string | number>>[], options?: DataSetInitialOptions<"id">): DataSet<Partial<Record<"id", string | number>>, "id">', gave the following error.
Argument of type '{ from: number; to: number; } []' is not assignable to parameter of type 'Partial<Record<"id", string | number>>[]'.
我正在使用 vis-network 的 5.2.4 版本。