首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >类型记录d3 -属性‘饼’在‘d3’类型上不存在

类型记录d3 -属性‘饼’在‘d3’类型上不存在
EN

Stack Overflow用户
提问于 2017-02-10 04:30:12
回答 2查看 7.7K关注 0票数 2

我在创建D3饼图时遇到了问题,如果我使用:

代码语言:javascript
运行
复制
/// < reference path="../typings/index.d.ts" />
import * as d3 from "d3"; 
d3.layout.pie< IData.IPie>().value(function (d) {

Grunt编译很好,但是它在浏览器中失败了,它说:

无法读取未定义的属性“饼”

这是因为d3 v4使用了以下方法:

d3.pie< IData.IPie>().value(function (d) {

但如果我改变了它,试着咕哝一遍,我就会得到:

类型‘d3’上不存在ts属性‘饼’。

有什么暗示吗?

node_modules/d3: "_id":"d3@4.5.0“

类型: https://raw.githubusercontent.com/types/npm-d3/a3171387d85d30049479ca880c617e63dca23afe/index.d.ts

编辑:

package.json

代码语言:javascript
运行
复制
{
  "name": "OpenCharts",
  "description": "It's time to easier beautiful charts",
  "version": "0.0.2",
  "devDependencies": {
    "@types/d3": "^4.5.0",
    "grunt": "^0.4.5",
    "grunt-contrib-concat": "~0.4.0",
    "grunt-contrib-nodeunit": "~0.4.1",
    "grunt-contrib-uglify": "~0.5.0",
    "grunt-ts": "^6.0.0-beta.3",
    "grunt-tslint": "^4.0.0"
  },
  "author": "Chriss Mejía",
  "license": "MIT",
  "dependencies": {
    "d3": "^4.4.0"
  }
}

并删除类型引用路径没有任何区别。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-02-10 17:47:18

基本上,与类型之间存在冲突,当我完全删除库时,它就开始工作了:

代码语言:javascript
运行
复制
typings uninstall d3
npm uninstall typings
票数 -1
EN

Stack Overflow用户

发布于 2017-02-10 04:51:33

看起来您使用的是版本3的type,而d3版本是4。

删除已安装的def类型,然后安装以下命令

代码语言:javascript
运行
复制
npm install @types/d3 --save-dev

Github回购:https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/d3

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42151545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档