var bar4 = new RGraph.Bar('cvs', [[21,31,13, 43,42, 25,42, 29,59, 28,40, 10]])
js对象实例化
 
如何实例化呢?
 
见下,如果不用this,不能为RGraph.Bar这个“类”添加属性,可以再调试的时候,发现这些属性是一个一个出现的
 
RGraph.Bar = function (id, data) { // Get the canvas and context objects
this.id = id;
this.canvas = document.getElementById(id);
this.context = this.canvas.getContext ? this.canvas.getContext("2d") : null;
this.canvas.__object__ = this;
this.type = 'bar';
this.max = 0;
this.stackedOrGrouped = false;
this.isRGraph = true;
this.uid = RGraph.CreateUID();
this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
this.colorsParsed = false;
}
 
里面放入方法也是正常的
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2021-11-02
  • 2022-03-02
猜你喜欢
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2021-12-23
  • 2022-01-30
  • 2021-10-21
  • 2022-12-23
相关资源
相似解决方案