我是使用Typescript的新手(2周),我正在研究包装d3.js框架的项目.我遇到了使用"d3.d.ts",命名空间,导出模块,导入的问题.
我的问题:当我尝试使用d3.scale.linear()时,我的浏览器控制台中出现错误:
    TypeError: d3.scale is undefined
代码 :
/// <reference path="../typings/d3.d.ts">;
"use strict";
var linear = d3.scale.linear();
console.log("linear resolv !")
我的编译器选项(我在编译过程中没有错误,但也许它很有趣):
{
    "files": [
        "src/twod3/workspace.ts",
        "src/twod3/component/basic.ts",
        "src/twod3/component/data.ts",
        "src/twod3/component/operation.ts",
        "src/main.ts"
    ],
    "compilerOptions": {
        "noImplicitAny": true,
        "target": "es2015",
        "module":"commonjs",
        "sourceMap":true
    }
}
我尝试了不同的导入策略而没有成功
d3.d.ts
declare namespace d3 {
...
    export module scale {
            ...
            export function linear(): Linear<number, number>;
            ...
     }
}
我不明白这个问题,谢谢你的帮助.
jco*_*ins 35
注意d3.js的版本 在版本4.2.1中d3.scale.linear(); 出现以下错误.TypeError:d3.scale.linear()scale未定义
我使用d3.scaleLinear()修复了4.2.1版本中的错误;
我有类似的问题。我必须匹配 D3 版本,它支持 d3 的内置方法。匹配 D3.js 的版本,确保更新浏览器或匹配当前版本的内置方法。
我支持的版本d3.scale.ordinal是“3.5.17”,之前我使用的是最新版本。
| 归档时间: | 
 | 
| 查看次数: | 11963 次 | 
| 最近记录: |