我知道JavaScript中的'this'与TypeScript中的含义不同,根据TypeScript中的这篇文章'this'.我在JavaScript中使用以下代码用于在所选节点上创建较粗的笔划,并为所有其他节点提供较小的笔划.
node.on('click', function (d) {
d3.selectAll('circle').attr('stroke-width', 1.5);
d3.select(this).select('circle').attr('stroke-width', 5);
})
Run Code Online (Sandbox Code Playgroud)
在TypeScript我有
this.node.on('click', (d:any) => {
this.node.selectAll('circle').attr('stroke-width', 1.5);
[this is where I need help].select('circle').attr('stroke-width', 5);
}
Run Code Online (Sandbox Code Playgroud)