angular - d3v5 Angular 8 生产模式 - ERROR TypeError: (void 0) is not a function
问题描述
D3v5 函数在开发模式下工作正常,但在生产模式下抛出运行时错误
错误类型错误:(void 0)不是函数
输入脚本代码
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 -升级到 Angular 8 后,还尝试根据 d3.js 中的错误更新目标
{
"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": ..
}
任何建议或线索将不胜感激。
谢谢
解决方案
对于遇到类似问题的任何人,我都可以通过将 d3 和 angular 碰撞到以下版本来使其工作
"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"
},
推荐阅读
- java - 在继承的类字段中使用 @ApiModelProperty 覆盖 swagger discerption/example
- karate - 如何在空手道 logback-test.xml 中传递变量
- python - dash 在选项卡中动态生成图表
- javascript - 如何在 Nuxt.js 中使用 Bootstrap 插件
- .net - 为什么阻塞的 Rx Timer 会第二次触发?
- variables - 如何从 CMS 页面 Magento2 向控制器发送参数
- python - 如何在 tkinter 中组合包和网格?
- excel - 将多个文本文件中的特定数据提取到一个工作表中
- python - 如何根据另一个有条件地格式化 Excel 工作表?
- java - thenComparing 中的错误不适用于参数 Comparator<..DTO>