【发布时间】:2020-03-12 21:07:17
【问题描述】:
D3v5 函数在开发模式下工作正常,但在生产模式下抛出运行时错误
ERROR TypeError: (void 0) is not a function
输入脚本代码
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))
}
}
包.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": ..
}
任何建议或线索将不胜感激。
谢谢
【问题讨论】:
-
您是否碰巧找到了解决此问题的有效解决方案?我也面临同样的问题。
-
我不得不修改版本,下面你会找到适合我的版本