我为这有多愚蠢而发火。这怎么可能?
console.log(typeof form.timeCompletedInSeconds);
console.log(typeof totalTimeCompletion);
console.log(totalTimeCompletion);
console.log(form.timeCompletedInSeconds);
totalTimeCompletion = form.timeCompletedInSecond + totalTimeCompletion;
console.log(totalTimeCompletion)
输出:
number
number
0
3
NaN
答案 0 :(得分:7)
您需要在第6行写timeCompletedInSeconds
而不是timeCompletedInSecond
。最后遗漏了s
,这就是为什么得到undefined + 3 = NaN
的原因。