TypeError:无法读取 nativescript 中未定义的属性“cartesianChart”

Posted

技术标签:

【中文标题】TypeError:无法读取 nativescript 中未定义的属性“cartesianChart”【英文标题】:TypeError: Cannot read property 'cartesianChart' of undefined in nativescript 【发布时间】:2018-08-04 20:40:18 【问题描述】:

我是 nativescript 中的一个新功能。我尝试在 nativescript 中学习图表,但它给出了“TypeError: Cannot read property 'cartesianChart' of undefined”错误。

home.componet.html

<RadCartesianChart tkExampleTitle tkToggleNavButton>
<CategoricalAxis tkCartesianHorizontalAxis></CategoricalAxis>
<LinearAxis tkCartesianVerticalAxis></LinearAxis>
<LineSeries tkCartesianSeries [items]="categoricalSource" categoryProperty="Country" valueProperty="Amount"></LineSeries>

home.component.ts

    import  Component, OnInit,ViewChild,AfterViewInit ,ElementRef from '@angular/core';
import  WebView, LoadEventData  from "ui/web-view";
import  ObservableArray  from "tns-core-modules/data/observable-array";
importDataService from "../data.service"
importCountry from "../country"

@Component(
  moduleId: module.id,
  selector: 'app-home',
  providers: [DataService],
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
)
export class HomeComponent implements OnInit 

  private _categoricalSource: ObservableArray<Country>;

  constructor(private _dataService: DataService)  

  get categoricalSource(): ObservableArray<Country> 
      return this._categoricalSource;
  

  ngOnInit() 
      this._categoricalSource = new ObservableArray(this._dataService.getCategoricalSource());
  


【问题讨论】:

【参考方案1】:

我遇到了同样的问题,通过删除android平台并重新添加它来解决它。

tns platform remove android
tns platform add android

【讨论】:

以上是关于TypeError:无法读取 nativescript 中未定义的属性“cartesianChart”的主要内容,如果未能解决你的问题,请参考以下文章

TypeError:无法读取未定义的属性(读取“国家”)

TypeError:无法读取未定义的属性(读取“名称”)

TypeError:无法读取属性“集合”[重复]

TypeError:无法读取 null 的属性(读取“发射”)

TypeError:无法读取未定义的属性(读取“匹配”):

TypeError:无法读取未定义的属性(读取“createContext”)