我使用包含的方法定义了以下对象:
function MaxHullSpeedCalculator(lwl) {
this.lwl = lwl;
}
MaxHullSpeedCalculator.prototype.calculate = function() {
var mhs = 1.34 * Math.sqrt(this.lwl);
return mhs.toFixed(2);
};
但是,当我尝试调用计算时:
var mhsc = new MaxHullSpeedCalculator(Ti.App.lwlBox.value);
mhsText.setText('Hull speed: ' + mhsc.calculate()); //throws error
我收到以下错误:
Exception occurred at outputWindow.js:51: Uncaught TypeError: Object #<MaxHullSpeedCalculator> has no method 'calculate'
有谁知道我做错了什么?