Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 财产';过渡';不存在于类型';选择<;BaseType,{},null,未定义>';_Javascript_Angular_D3.js_Transition - Fatal编程技术网

Javascript 财产';过渡';不存在于类型';选择<;BaseType,{},null,未定义>';

Javascript 财产';过渡';不存在于类型';选择<;BaseType,{},null,未定义>';,javascript,angular,d3.js,transition,Javascript,Angular,D3.js,Transition,我想在angular2中使用d3js,但当我想在元素更改时添加转换时,会出现一个错误: 类型“Selection”上不存在属性“transition” 我使用angular cli生成项目,angular的版本是4.0.0,d3js是4.8.0 这是我的打字。d.ts: declare module 'd3' { export * from 'd3-array'; export * from 'd3-axis'; export * from 'd3-brush'; export * from '

我想在angular2中使用d3js,但当我想在元素更改时添加转换时,会出现一个错误:
类型“Selection”上不存在属性“transition”
我使用angular cli生成项目,angular的版本是4.0.0,d3js是4.8.0

这是我的
打字。d.ts

declare module 'd3' {
export * from 'd3-array';
export * from 'd3-axis';
export * from 'd3-brush';
export * from 'd3-chord';
export * from 'd3-collection';
export * from 'd3-color';
export * from 'd3-dispatch';
export * from 'd3-drag';
export * from 'd3-dsv';
export * from 'd3-ease';
export * from 'd3-force';
export * from 'd3-format';
export * from 'd3-geo';
export * from 'd3-hierarchy';
export * from 'd3-interpolate';
export * from 'd3-path';
export * from 'd3-polygon';
export * from 'd3-quadtree';
export * from 'd3-queue';
export * from 'd3-random';
export * from 'd3-request';
export * from 'd3-scale';
export * from 'd3-selection';
export * from 'd3-shape';
export * from 'd3-time';
export * from 'd3-time-format';
export * from 'd3-timer';
export * from 'd3-transition';
export * from 'd3-voronoi';
export * from 'd3-zoom';
}

这是我的app.component.ts

import * as d3 from 'd3';
......
d3.select(this).select("path").transition().attr("d", function(d) {
            console.log(d);
            return arc2(<any>d);
        })
import*从“d3”作为d3导入;
......
d3.select(this).select(“path”).transition().attr(“d”),function(d){
控制台日志(d);
返回弧2(d);
})
如果我删除
transition()
,它的性能会很好


如何解决?谢谢

我已通过以下方式修复了我的代码:

import { select as d3Select } from 'd3-selection';
import { transition as d3Transition } from 'd3-transition';
d3Select.prototype.transition = d3Transition;
然后在代码中使用d3Select而不是select

您可以按照以下步骤操作:

你能在JSFIDLE上发布吗?@TheBiro这是github的报告,我不知道如何在JSFIDLE中生成angular4演示,对不起,我尝试了npm卸载——保存dev@types/d3,然后重新启动项目,一切正常,没有发生错误,所以说@types/d3有bug?嗯。我发现了问题。。我不使用npm来安装软件包