D3v5函数在开发模式下工作良好,但在生产模式中抛出运行时错误。
ERROR TypeError:(Void0)不是函数
类型脚本代码
import { Component } from '@angular/core';
import {timeFormat} from 'd3-time-format';
...
export class AppComponent {
constructor(){
var formatTime = timeFormat("%B %d, %Y");
console.log('Time parser :: ', formatTime(new Date))
}
}Package.json
"dependencies": {
"@angular/animations": "~8.1.1",
"@angular/common": "~8.1.1",
"@angular/compiler": "~8.1.1",
"@angular/core": "~8.1.1",
"@angular/forms": "~8.1.1",
"@angular/platform-browser": "~8.1.1",
"@angular/platform-browser-dynamic": "~8.1.1",
"@angular/router": "~8.1.1",
"@types/d3": "^5.7.2",
"d3": "^5.13.1",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},tsconfig.json -也尝试按照Error in d3.js after upgrading to Angular 8更新目标
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
**"target": "es5",**
"typeRoots": [
"node_modules/@types"
],
"lib": ..
},
"angularCompilerOptions": ..
}如有任何建议或线索,将不胜感激。
谢谢
发布于 2019-11-20 07:16:28
对于任何遇到类似问题的人,我都可以通过将d3和角转到下面的版本来使它工作。
"dependencies": {
"@angular/animations": "~8.2.14",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"@types/d3": "^5.7.2",
"d3": "^5.14.0",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},发布于 2019-12-11 06:55:52
更新@角-devkit/build版本之后,
“@angular/build-角”:"~0.801.2“
至
“@angular/build”:"^0.803.17“
为我工作。
https://stackoverflow.com/questions/58898594
复制相似问题