本文介绍了升级到Angular 8后d3.js中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我已将我的 Angular 4 应用程序更新为 Angular 8 .应用程序在开发人员构建中工作正常,但在产品构建中中断.加载应用程序时出现以下错误.

I have updated my Angular 4 app to Angular 8. Application works fine in dev build but breaks in prod build. I get the following error when loading the application.

我的 tsconfig.json 文件如下所示.

{
  "compileOnSave": false,
  "compilerOptions": {
  "importHelpers": true,
  "outDir": "./dist/out-tsc",
  "baseUrl": "src",
  "sourceMap": true,
  "declaration": false,
  "moduleResolution": "node",
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "target": "es2015",
  "typeRoots": [
    "node_modules/@types"
  ],
  "lib": [
    "es2016",
    "dom"
  ],
  "module": "esnext",
  "paths": {
    "core-js/es7/reflect": ["../node_modules/core-js/proposals/reflect-
     metadata"],
    "core-js/es6/*": ["../node_modules/core-js/es/*"]
  }
 }
}

我尝试将目标从 es2015 更改为 es5 ,但没有成功,并给了我vendor.js错误任何帮助,将不胜感激.谢谢

I tried changing the target from es2015 to es5 with no success and gave me an error in vendor.jsAny help would be appreciated. Thanks

推荐答案

我通过将 tsconfig.json 文件中的目标从 es2015 更改为来解决此问题. es5 .到目前为止,d3库与es2015不兼容.

I fixed the issue by changing the target in tsconfig.json file from es2015 to es5. d3 library is not compatible with es2015 as of yet.

由于使用诸如π之类的UTF-8符号,因此在d3.js中抛出错误.要解决此问题,您可以在HTML宿主文档上指定UTF-8字符集.

And that in return throws an error in d3.js because of the use of UTF-8 symbols such as π. To fix that you can specify the UTF-8 charset on the HTML host document.

<meta http-equiv="content-type" content="text/html; charset=UTF8">

这篇关于升级到Angular 8后d3.js中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 09:28