我正在尝试使用另一个网站上的示例代码来使用原型功能。我已经简化了代码并在下面列出。当我在我的网站上实现代码时,我会得到以下错误:TypeError: this.createChart不是一个函数。只有在尝试实现代码时才会出现此错误,而在jsfiddle上则没有出现此错误。这是我的工作jsfiddle:http://jsfiddle.net/56vjtv3d/76。有什么建议吗?谢谢!
function Meteogram(A,B) {
this.A = A;
this.B = B;
this.createChart();
}
Meteogram.prototype.createChart = function() {
alert('test');
//Will do other stuff here
};
new Meteogram()
)对我来说是正常工作的,我在 JSFiddle 中也没有看到任何错误。 - Andrew Burgess