我有這樣的方法:使用Javascript - 遺漏的類型錯誤:對象沒有方法
var stopwatch = function() {
this.start = function() {
(...)
};
this.stop = function() {
(...)
};
};
當我嘗試調用它:
stopwatch.start();
我得到Uncaught TypeError: Object (here is my function) has no method 'start'
。我究竟做錯了什麼?
因爲你以後無法結束這種秒錶而不保存在一個變量。 – DCoder
那麼,爲什麼不把實例賦值給一個變量,就像其他答案一樣呢? :P – Quv