【发布时间】:2020-08-27 09:21:49
【问题描述】:
我正在尝试使用 typescript 实现 d3 输入、更新、删除模式
来源: https://codesandbox.io/s/brave-banach-g1h51?file=/src/index.ts
import { select } from "d3-selection";
const chart = select("#chart");
const values = [1, 2, 3, 4, 5];
const node = chart.selectAll("g.node").data(values);
const nodeEnter = node
.enter()
.append("g")
.attr("class", "node");
// Type Error here
const nodeUpdate = nodeEnter.merge(node);
node.exit().remove();
但我在这个问题上遇到了错误:
Argument of type
'Selection<BaseType, number, BaseType, unknown>' is not assignable to parameter of type
'Selection<SVGGElement, number, BaseType, unknown>'.
Types of property 'select' are incompatible.
我该如何解决?
【问题讨论】:
标签: typescript d3.js typescript-typings