【问题标题】:Ngx-charts : Cannot read property length of undefinedNgx-charts:无法读取未定义的属性长度
【发布时间】:2017-09-21 03:29:50
【问题描述】:

我正在尝试使用泳道 NGX-charts [Single line chart not multi] 来实现折线图。但我收到一个错误,说:无法读取未定义的属性长度

我正在使用

angular-cli:1.0.0-beta.25.5
节点:v7.2.1 npm : 3.10.10
@swimlane/ngx-charts" : "^4.0.0

我卸载了 ng2-charts、chart.js 库,但仍然出现此错误

日志:

ViewWrappedError__zone_symbol__error: Error: Error in ./ProgressReportComponent class ProgressReportComponent - inline template:62:56 caused by: Cannot read property 'length' of undefined
    at ViewWrappedError.Error (native)
    at ViewWrappedError.ZoneAwareError (http://localhost:4200/vendor.bundle.js:201399:33)
    at ViewWrappedError.BaseError [as constructor] 
TypeError: Cannot read property 'length' of undefined(…)

【问题讨论】:

    标签: angularjs charts


    【解决方案1】:

    你正在根据这一行安装最新的 ngx-charts

    @swimlane/ngx-charts" : "^4.0.0"
    

    package.json 依赖项上的这个符号 ^ 指示 npm 包管理器下载最新版本的 ngx-charts abocve 4.0.0 而不是确切的 4.0.0,所以可能你有 ngx-charts 5 版本,仅适用于根据github页面的角度4(https://github.com/swimlane/ngx-charts)。

    您正在使用 angular-cli beta,因此如果我们假设您尚未更新 angular 依赖项,您仍然使用 angular 版本 2。

    你有两个选择:

    1. 考虑在 Angular 4 上更新
    2. 为 ngx-charts (@swimlane/ngx-charts" : "4.0.0") 从 package.json 中删除 ^ 符号,删除 node_modules 文件夹 并运行 npm install。

    【讨论】:

      猜你喜欢
      • 2021-10-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-10
      • 2020-09-14
      • 2018-01-11
      相关资源
      最近更新 更多